home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / cp / parse.y < prev    next >
Text File  |  1994-07-06  |  109KB  |  3,755 lines

  1. /* YACC parser for C++ syntax.
  2.    Copyright (C) 1988, 1989, 1993 Free Software Foundation, Inc.
  3.    Hacked by Michael Tiemann (tiemann@cygnus.com)
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. /* This grammar is based on the GNU CC grammar.  */
  23.  
  24. /* Note: Bison automatically applies a default action of "$$ = $1" for
  25.    all derivations; this is applied before the explicit action, if one
  26.    is given.  Keep this in mind when reading the actions.  */
  27.  
  28. /* Also note: this version contains experimental exception
  29.    handling features.  They could break, change, disappear,
  30.    or otherwise exhibit volatile behavior.  Don't depend on
  31.    me (Michael Tiemann) to protect you from any negative impact
  32.    this may have on your professional, personal, or spiritual life.
  33.  
  34.    NEWS FLASH:  This version now supports the exception handling
  35.    syntax of Stroustrup's 2nd edition, if -fansi-exceptions is given.
  36.    THIS IS WORK IN PROGRESS!!!  The type of the 'throw' and the
  37.    'catch' much match EXACTLY (no inheritance support or coercions).
  38.    Also, throw-specifications of functions don't work.
  39.    Destructors aren't called correctly.  Etc, etc.  --Per Bothner.
  40.   */
  41.  
  42. %{
  43. /* Cause the `yydebug' variable to be defined.  */
  44. #define YYDEBUG 1
  45.  
  46. #include "config.h"
  47.  
  48. #include <stdio.h>
  49. #include <errno.h>
  50.  
  51. #include "tree.h"
  52. #include "input.h"
  53. #include "flags.h"
  54. #include "lex.h"
  55. #include "cp-tree.h"
  56.  
  57. /* Since parsers are distinct for each language, put the language string
  58.    definition here.  (fnf) */
  59. char *language_string = "GNU C++";
  60.  
  61. extern tree void_list_node;
  62. extern struct obstack permanent_obstack;
  63.  
  64. #ifndef errno
  65. extern int errno;
  66. #endif
  67.  
  68. extern int end_of_file;
  69. extern int current_class_depth;
  70.  
  71. void yyerror ();
  72.  
  73. /* Like YYERROR but do call yyerror.  */
  74. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  75.  
  76. #define OP0(NODE) (TREE_OPERAND (NODE, 0))
  77. #define OP1(NODE) (TREE_OPERAND (NODE, 1))
  78.  
  79. /* Contains the statement keyword (if/while/do) to include in an
  80.    error message if the user supplies an empty conditional expression.  */
  81. static char *cond_stmt_keyword;
  82.  
  83. /* Nonzero if we have an `extern "C"' acting as an extern specifier.  */
  84. int have_extern_spec;
  85. int used_extern_spec;
  86.  
  87. void yyhook ();
  88.  
  89. /* Cons up an empty parameter list.  */
  90. #ifdef __GNUC__
  91. __inline
  92. #endif
  93. static tree
  94. empty_parms ()
  95. {
  96.   tree parms;
  97.  
  98.   if (strict_prototype)
  99.     parms = void_list_node;
  100.   else
  101.     parms = NULL_TREE;
  102.   return parms;
  103. }
  104. %}
  105.  
  106. %start program
  107.  
  108. %union {long itype; tree ttype; char *strtype; enum tree_code code; }
  109.  
  110. /* All identifiers that are not reserved words
  111.    and are not declared typedefs in the current block */
  112. %token IDENTIFIER
  113.  
  114. /* All identifiers that are declared typedefs in the current block.
  115.    In some contexts, they are treated just like IDENTIFIER,
  116.    but they can also serve as typespecs in declarations.  */
  117. %token TYPENAME
  118.  
  119. /* Reserved words that specify storage class.
  120.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  121. %token SCSPEC
  122.  
  123. /* Reserved words that specify type.
  124.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  125. %token TYPESPEC
  126.  
  127. /* Reserved words that qualify type: "const" or "volatile".
  128.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  129. %token TYPE_QUAL
  130.  
  131. /* Character or numeric constants.
  132.    yylval is the node for the constant.  */
  133. %token CONSTANT
  134.  
  135. /* String constants in raw form.
  136.    yylval is a STRING_CST node.  */
  137. %token STRING
  138.  
  139. /* "...", used for functions with variable arglists.  */
  140. %token ELLIPSIS
  141.  
  142. /* the reserved words */
  143. /* SCO include files test "ASM", so use something else. */
  144. %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  145. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF
  146. %token HEADOF CLASSOF SIGOF
  147. %token ATTRIBUTE EXTENSION LABEL
  148.  
  149. /* the reserved words... C++ extensions */
  150. %token <ttype> AGGR
  151. %token <itype> VISSPEC
  152. %token DELETE NEW OVERLOAD THIS OPERATOR CXX_TRUE CXX_FALSE
  153. %token LEFT_RIGHT TEMPLATE
  154. %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
  155. %token <itype> SCOPE
  156.  
  157. /* Define the operator tokens and their precedences.
  158.    The value is an integer because, if used, it is the tree code
  159.    to use in the expression made from the operator.  */
  160.  
  161. %left EMPTY            /* used to resolve s/r with epsilon */
  162.  
  163. %left error
  164.  
  165. /* Add precedence rules to solve dangling else s/r conflict */
  166. %nonassoc IF
  167. %nonassoc ELSE
  168.  
  169. %left IDENTIFIER TYPENAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR
  170.  
  171. %left '{' ',' ';'
  172.  
  173. %right <code> ASSIGN '='
  174. %right <code> '?' ':'
  175. %left <code> OROR
  176. %left <code> ANDAND
  177. %left <code> '|'
  178. %left <code> '^'
  179. %left <code> '&'
  180. %left <code> MIN_MAX
  181. %left <code> EQCOMPARE
  182. %left <code> ARITHCOMPARE '<' '>'
  183. %left <code> LSHIFT RSHIFT
  184. %left <code> '+' '-'
  185. %left <code> '*' '/' '%'
  186. %left <code> POINTSAT_STAR DOT_STAR
  187. %right <code> UNARY PLUSPLUS MINUSMINUS '~'
  188. %left HYPERUNARY
  189. %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
  190. %left <code> POINTSAT '.' '(' '['
  191.  
  192. %right SCOPE            /* C++ extension */
  193. %nonassoc NEW DELETE TRY CATCH THROW
  194.  
  195. %type <code> unop
  196.  
  197. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
  198. %type <ttype> paren_expr_or_null nontrivial_exprlist
  199. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  200. %type <ttype> typed_declspecs reserved_declspecs boolean.literal
  201. %type <ttype> typed_typespecs reserved_typespecquals
  202. %type <ttype> declmods typespec typespecqual_reserved
  203. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  204. %type <itype> initdecls notype_initdecls initdcl    /* C++ modification */
  205. %type <ttype> init initlist maybeasm
  206. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  207. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  208. %type <ttype> any_word
  209.  
  210. %type <ttype> compstmt implicitly_scoped_stmt
  211.  
  212. %type <ttype> declarator notype_declarator after_type_declarator
  213. %type <ttype> direct_notype_declarator direct_after_type_declarator
  214.  
  215. %type <ttype> structsp opt.component_decl_list component_decl_list
  216. %type <ttype> component_decl components component_declarator
  217. %type <ttype> notype_components notype_component_declarator
  218. %type <ttype> after_type_component_declarator after_type_component_declarator0
  219. %type <ttype> notype_component_declarator0 component_decl_1
  220. %type <ttype> enumlist enumerator
  221. %type <ttype> type_id absdcl type_quals
  222. %type <ttype> direct_abstract_declarator conversion_declarator
  223. %type <ttype> new_type_id new_declarator direct_new_declarator
  224. %type <ttype> xexpr parmlist parms parm bad_parm
  225. %type <ttype> identifiers_or_typenames
  226. %type <ttype> fcast_or_absdcl regcast_or_absdcl sub_cast_expr
  227. %type <ttype> expr_or_declarator complex_notype_declarator
  228. %type <ttype> notype_unqualified_id unqualified_id qualified_id
  229. %type <ttype> overqualified_id notype_qualified_id
  230. %type <ttype> complex_direct_notype_declarator functional_cast
  231. %type <ttype> named_parm complex_parmlist typed_declspecs1 parms_comma
  232.  
  233. /* C++ extensions */
  234. %token <ttype> TYPENAME_ELLIPSIS PTYPENAME
  235. %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
  236. %token <ttype> PRE_PARSED_CLASS_DECL
  237. %type <ttype> fn.def1 /* Not really! */
  238. %type <ttype> fn.def2 return_id
  239. %type <ttype> named_class_head named_class_head_sans_basetype
  240. %type <ttype> unnamed_class_head
  241. %type <ttype> class_head base_class_list
  242. %type <itype> base_class_access_list
  243. %type <ttype> base_class maybe_base_class_list base_class.1
  244. %type <ttype> maybe_raises ansi_raise_identifier ansi_raise_identifiers
  245. %type <ttype> component_declarator0
  246. %type <ttype> forhead.1 operator_name
  247. %type <ttype> object aggr
  248. %type <itype> new delete
  249. /* %type <ttype> primary_no_id */
  250. %type <ttype> nonmomentary_expr
  251. %type <itype> forhead.2 initdcl0 notype_initdcl0 member_init_list
  252. %type <ttype> template_header template_parm_list template_parm
  253. %type <ttype> template_type template_arg_list template_arg
  254. %type <ttype> template_instantiation template_type_name tmpl.2
  255. %type <ttype> template_instantiate_once template_instantiate_some
  256. %type <itype> fn_tmpl_end
  257. /* %type <itype> try_for_typename */
  258. %type <ttype> condition xcond paren_cond_or_null
  259. %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
  260. %type <ttype> qualified_type_name complete_type_name notype_identifier
  261. %type <ttype> complex_type_name nested_name_specifier_1
  262. %type <itype> nomods_initdecls nomods_initdcl0
  263. %type <ttype> new_initializer new_placement specialization type_specifier_seq
  264.  
  265. /* in order to recognize aggr tags as defining and thus shadowing. */
  266. %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
  267. %type <ttype> named_class_head_sans_basetype_defn 
  268. %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
  269.  
  270. %type <strtype> .pushlevel
  271.  
  272. /* spew.c depends on this being the last token.  Define
  273.    any new tokens before this one!  */
  274. %token END_OF_SAVED_INPUT
  275.  
  276. %{
  277. /* List of types and structure classes of the current declaration.  */
  278. static tree current_declspecs;
  279.  
  280. /* When defining an aggregate, this is the most recent one being defined.  */
  281. static tree current_aggr;
  282.  
  283. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  284.  
  285. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  286. extern void yyprint ();
  287. extern tree combine_strings        PROTO((tree));
  288. %}
  289.  
  290. %%
  291. program: /* empty */
  292.     | extdefs
  293.         {
  294.           /* In case there were missing closebraces,
  295.              get us back to the global binding level.  */
  296.           while (! global_bindings_p ())
  297.             poplevel (0, 0, 0);
  298.           finish_file ();
  299.         }
  300.     ;
  301.  
  302. /* the reason for the strange actions in this rule
  303.  is so that notype_initdecls when reached via datadef
  304.  can find a valid list of type and sc specs in $0. */
  305.  
  306. extdefs:
  307.       { $<ttype>$ = NULL_TREE; } lang_extdef
  308.         { $<ttype>$ = NULL_TREE; }
  309.     | extdefs lang_extdef
  310.         { $<ttype>$ = NULL_TREE; }
  311.     ;
  312.  
  313. .hush_warning:
  314.         { have_extern_spec = 1;
  315.           used_extern_spec = 0;
  316.           $<ttype>$ = NULL_TREE; }
  317.     ;
  318. .warning_ok:
  319.         { have_extern_spec = 0; }
  320.     ;
  321.  
  322. asm_keyword:
  323.       ASM_KEYWORD
  324.     | GCC_ASM_KEYWORD
  325.     ;
  326.  
  327. lang_extdef:
  328.       { if (pending_lang_change) do_pending_lang_change(); }
  329.       extdef
  330.       { if (! global_bindings_p () && ! pseudo_global_level_p())
  331.           pop_everything (); }
  332.     ;
  333.  
  334. extdef:
  335.       fndef
  336.         { if (pending_inlines) do_pending_inlines (); }
  337.     | datadef
  338.         { if (pending_inlines) do_pending_inlines (); }
  339.     | template_def
  340.         { if (pending_inlines) do_pending_inlines (); }
  341.     | overloaddef
  342.     | asm_keyword '(' string ')' ';'
  343.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  344.           assemble_asm ($3); }
  345.     | extern_lang_string '{' extdefs '}'
  346.         { pop_lang_context (); }
  347.     | extern_lang_string '{' '}'
  348.         { pop_lang_context (); }
  349.     | extern_lang_string .hush_warning fndef .warning_ok
  350.         { if (pending_inlines) do_pending_inlines ();
  351.           pop_lang_context (); }
  352.     | extern_lang_string .hush_warning datadef .warning_ok
  353.         { if (pending_inlines) do_pending_inlines ();
  354.           pop_lang_context (); }
  355.     ;
  356.  
  357. extern_lang_string:
  358.       EXTERN_LANG_STRING
  359.         { push_lang_context ($1); }
  360.     ;
  361.  
  362. template_header:
  363.       TEMPLATE '<'
  364.         { begin_template_parm_list (); }
  365.       template_parm_list '>'
  366.         { $$ = end_template_parm_list ($4); }
  367.     ;
  368.  
  369. template_parm_list:
  370.       template_parm
  371.         { $$ = process_template_parm (NULL_TREE, $1); }
  372.     | template_parm_list ',' template_parm
  373.         { $$ = process_template_parm ($1, $3); }
  374.     ;
  375.  
  376. template_parm:
  377.     /* The following rules introduce a new reduce/reduce
  378.        conflict on the ',' and '>' input tokens: they are valid
  379.        prefixes for a `structsp', which means they could match a
  380.        nameless parameter.  See 14.6, paragraph 3.
  381.        By putting them before the `parm' rule, we get
  382.        their match before considering them nameless parameter
  383.        declarations.  */
  384.       aggr identifier
  385.         {
  386.           if ($1 == signature_type_node)
  387.             sorry ("signature as template type parameter");
  388.           else if ($1 != class_type_node)
  389.             error ("template type parameter must use keyword `class'");
  390.           $$ = build_tree_list ($2, NULL_TREE);
  391.         }
  392.     | aggr identifier_defn ':' base_class.1
  393.         {
  394.           if ($1 == signature_type_node)
  395.             sorry ("signature as template type parameter");
  396.           else if ($1 != class_type_node)
  397.             error ("template type parameter must use keyword `class'");
  398.           warning ("restricted template type parameters not yet implemented");
  399.           $$ = build_tree_list ($2, $4);
  400.         }
  401.     | parm
  402.     ;
  403.  
  404. overloaddef:
  405.       OVERLOAD ov_identifiers ';'
  406.         { warning ("use of `overload' is an anachronism"); }
  407.     ;
  408.  
  409. ov_identifiers: IDENTIFIER
  410.         { declare_overloaded ($1); }
  411.     | ov_identifiers ',' IDENTIFIER
  412.         { declare_overloaded ($3); }
  413.     ;
  414.       
  415. template_def:
  416.     /* Class template declarations go here; they aren't normal class
  417.        declarations, because we can't process the bodies yet.  */
  418.       template_header named_class_head_sans_basetype '{'
  419.         { yychar = '{'; goto template1; }
  420.      ';'
  421.     | template_header named_class_head_sans_basetype_defn '{'
  422.         { yychar = '{'; goto template1; }
  423.      ';'
  424.     | template_header named_class_head_sans_basetype ':'
  425.         { yychar = ':'; goto template1; }
  426.      ';'
  427.     | template_header named_class_head_sans_basetype_defn ':'
  428.         {
  429.           yychar = ':';
  430.         template1:
  431.           if (current_aggr == exception_type_node)
  432.             error ("template type must define an aggregate or union");
  433.           else if (current_aggr == signature_type_node)
  434.             sorry ("template type defining a signature");
  435.           /* Maybe pedantic warning for union?
  436.              How about an enum? :-)  */
  437.           end_template_decl ($1, $2, current_aggr, 1);
  438.           reinit_parse_for_template (yychar, $1, $2);
  439.           yychar = YYEMPTY;
  440.         }
  441.       ';'
  442.     | template_header named_class_head_sans_basetype ';'
  443.         {
  444.           end_template_decl ($1, $2, current_aggr, 0);
  445.           /* declare $2 as template name with $1 parm list */
  446.         }
  447.     | template_header named_class_head_sans_basetype_defn ';'
  448.         {
  449.           end_template_decl ($1, $2, current_aggr, 0);
  450.           /* declare $2 as template name with $1 parm list */
  451.         }
  452.     | template_header /* notype_initdcl0 ';' */
  453.       notype_declarator maybe_raises maybeasm maybe_attribute
  454.       fn_tmpl_end
  455.         {
  456.           tree d;
  457.           int momentary;
  458.           int def = ($6 != ';');
  459.           momentary = suspend_momentary ();
  460.           d = start_decl ($<ttype>2, /*current_declspecs*/NULL_TREE, 0,
  461.                   $3);
  462.           cplus_decl_attributes (d, $5);
  463.           finish_decl (d, NULL_TREE, $4, 0);
  464.           end_template_decl ($1, d, 0, def);
  465.           if (def)
  466.             reinit_parse_for_template ((int) $6, $1, d);
  467.           resume_momentary (momentary);
  468.         }
  469.     | template_header typed_declspecs /*initdcl0*/
  470.       declarator maybe_raises maybeasm maybe_attribute
  471.       fn_tmpl_end
  472.         {
  473.           tree d;
  474.           int momentary;
  475.           int def = ($7 != ';');
  476.  
  477.           current_declspecs = $2;
  478.           momentary = suspend_momentary ();
  479.           d = start_decl ($<ttype>3, current_declspecs,
  480.                   0, $<ttype>4);
  481.           cplus_decl_attributes (d, $6);
  482.           finish_decl (d, NULL_TREE, $5, 0);
  483.           end_template_decl ($1, d, 0, def);
  484.           if (def)
  485.             {
  486.               reinit_parse_for_template ((int) $7, $1, d);
  487.               yychar = YYEMPTY;
  488.             }
  489.           note_list_got_semicolon ($<ttype>2);
  490.           resume_momentary (momentary);
  491.         }
  492.     | template_header declmods notype_declarator fn_tmpl_end
  493.         {
  494.           int def = ($4 != ';');
  495.           tree d = start_decl ($<ttype>3, $<ttype>2, 0, NULL_TREE);
  496.           finish_decl (d, NULL_TREE, NULL_TREE, 0);
  497.           end_template_decl ($1, d, 0, def);
  498.           if (def)
  499.             reinit_parse_for_template ((int) $4, $1, d);
  500.         }
  501.     /* Try to recover from syntax errors in templates.  */
  502.     | template_header error '}'    { end_template_decl ($1, 0, 0, 0); }
  503.     | template_header error ';'    { end_template_decl ($1, 0, 0, 0); }
  504.     ;
  505.  
  506. fn_tmpl_end: '{'        { $$ = '{'; }
  507.     | ':'            { $$ = ':'; }
  508.     | ';'            { $$ = ';'; }
  509.     | '='            { $$ = '='; }
  510.     | RETURN        { $$ = RETURN; }
  511.     ;
  512.  
  513. datadef:
  514.       nomods_initdecls ';'
  515.         {}
  516.     | declmods notype_initdecls ';'
  517.         {}
  518.     /* Normal case to make fast: "const i;".  */
  519.     | declmods notype_declarator ';'
  520.         { tree d;
  521.           d = start_decl ($<ttype>2, $<ttype>$, 0, NULL_TREE);
  522.           finish_decl (d, NULL_TREE, NULL_TREE, 0);
  523.         }
  524.     | typed_declspecs initdecls ';'
  525.         {
  526.           note_list_got_semicolon ($<ttype>$);
  527.         }
  528.     /* Normal case: make this fast.  */
  529.     | typed_declspecs declarator ';'
  530.         { tree d;
  531.           d = start_decl ($<ttype>2, $<ttype>$, 0, NULL_TREE);
  532.           finish_decl (d, NULL_TREE, NULL_TREE, 0);
  533.           note_list_got_semicolon ($<ttype>$);
  534.         }
  535.         | declmods ';'
  536.       { pedwarn ("empty declaration"); }
  537.     | explicit_instantiation ';'
  538.     | typed_declspecs ';'
  539.       {
  540.         tree t = $<ttype>$;
  541.         shadow_tag (t);
  542.         if (TREE_CODE (t) == TREE_LIST
  543.         && TREE_PURPOSE (t) == NULL_TREE)
  544.           {
  545.         t = TREE_VALUE (t);
  546.         if (IS_AGGR_TYPE (t)
  547.             && IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (t)))
  548.           {
  549.             if (CLASSTYPE_USE_TEMPLATE (t) == 0)
  550.               SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
  551.             else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
  552.               error ("override declaration for already-expanded template");
  553.           }
  554.           }
  555.         note_list_got_semicolon ($<ttype>$);
  556.       }
  557.     | error ';'
  558.     | error '}'
  559.     | ';'
  560.     ;
  561.  
  562. fndef:
  563.       fn.def1 base_init compstmt_or_error
  564.         {
  565.           finish_function (lineno, 1);
  566.           /* finish_function performs these three statements:
  567.  
  568.              expand_end_bindings (getdecls (), 1, 0);
  569.              poplevel (1, 1, 0);
  570.  
  571.              expand_end_bindings (0, 0, 0);
  572.              poplevel (0, 0, 1);
  573.              */
  574.           if ($<ttype>$) process_next_inline ($<ttype>$);
  575.         }
  576.     | fn.def1 return_init base_init compstmt_or_error
  577.         {
  578.           finish_function (lineno, 1);
  579.           /* finish_function performs these three statements:
  580.  
  581.              expand_end_bindings (getdecls (), 1, 0);
  582.              poplevel (1, 1, 0);
  583.  
  584.              expand_end_bindings (0, 0, 0);
  585.              poplevel (0, 0, 1);
  586.              */
  587.           if ($<ttype>$) process_next_inline ($<ttype>$);
  588.         }
  589.     | fn.def1 nodecls compstmt_or_error
  590.         { finish_function (lineno, 0);
  591.           if ($<ttype>$) process_next_inline ($<ttype>$); }
  592.     | fn.def1 return_init ';' nodecls compstmt_or_error
  593.         { finish_function (lineno, 0);
  594.           if ($<ttype>$) process_next_inline ($<ttype>$); }
  595.     | fn.def1 return_init nodecls compstmt_or_error
  596.         { finish_function (lineno, 0);
  597.           if ($<ttype>$) process_next_inline ($<ttype>$); }
  598.     | typed_declspecs declarator error
  599.         {}
  600.     | declmods notype_declarator error
  601.         {}
  602.     | notype_declarator error
  603.         {}
  604.     ;
  605.  
  606. fn.def1:
  607.       typed_declspecs declarator maybe_raises
  608.         { if (! start_function ($$, $2, $3, 0))
  609.             YYERROR1;
  610.           reinit_parse_for_function ();
  611.           $$ = NULL_TREE; }
  612.     | declmods notype_declarator maybe_raises
  613.         { if (! start_function ($$, $2, $3, 0))
  614.             YYERROR1;
  615.           reinit_parse_for_function ();
  616.           $$ = NULL_TREE; }
  617.     | notype_declarator maybe_raises
  618.         { if (! start_function (NULL_TREE, $$, $2, 0))
  619.             YYERROR1;
  620.           reinit_parse_for_function ();
  621.           $$ = NULL_TREE; }
  622.     | PRE_PARSED_FUNCTION_DECL
  623.         { start_function (NULL_TREE, TREE_VALUE ($$), NULL_TREE, 1);
  624.           reinit_parse_for_function (); }
  625.     ;
  626.  
  627. /* more C++ complexity.  See component_decl for a comment on the
  628.    reduce/reduce conflict introduced by these rules.  */
  629. fn.def2:
  630.       typed_declspecs '(' parmlist ')' type_quals maybe_raises
  631.         {
  632.           $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1), $3, $5);
  633.           $$ = start_method (TREE_CHAIN ($1), $$, $6);
  634.          rest_of_mdef:
  635.           if (! $$)
  636.             YYERROR1;
  637.           if (yychar == YYEMPTY)
  638.             yychar = YYLEX;
  639.           reinit_parse_for_method (yychar, $$); }
  640.     | typed_declspecs LEFT_RIGHT type_quals maybe_raises
  641.         {
  642.           $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1),
  643.                      empty_parms (), $3);
  644.           $$ = start_method (TREE_CHAIN ($1), $$, $4);
  645.           goto rest_of_mdef;
  646.         }
  647.     | typed_declspecs declarator maybe_raises
  648.         { $$ = start_method ($$, $2, $3); goto rest_of_mdef; }
  649.     | declmods notype_declarator maybe_raises
  650.         { $$ = start_method ($$, $2, $3); goto rest_of_mdef; }
  651.     | notype_declarator maybe_raises
  652.         { $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; }
  653.     ;
  654.  
  655. return_id: RETURN IDENTIFIER
  656.         {
  657.           if (! current_function_parms_stored)
  658.             store_parm_decls ();
  659.           $$ = $2;
  660.         }
  661.     ;
  662.  
  663. return_init: return_id
  664.         { store_return_init ($<ttype>$, NULL_TREE); }
  665.     | return_id '=' init
  666.         { store_return_init ($<ttype>$, $3); }
  667.     | return_id '(' nonnull_exprlist ')'
  668.         { store_return_init ($<ttype>$, $3); }
  669.     | return_id LEFT_RIGHT
  670.         { store_return_init ($<ttype>$, NULL_TREE); }
  671.     ;
  672.  
  673. base_init:
  674.       ':' .set_base_init member_init_list
  675.         {
  676.           if ($3 == 0)
  677.             error ("no base initializers given following ':'");
  678.           setup_vtbl_ptr ();
  679.           /* Always keep the BLOCK node associated with the outermost
  680.              pair of curley braces of a function.  These are needed
  681.              for correct operation of dwarfout.c.  */
  682.           keep_next_level ();
  683.         }
  684.     ;
  685.  
  686. .set_base_init:
  687.     /* empty */
  688.         {
  689.           if (! current_function_parms_stored)
  690.             store_parm_decls ();
  691.  
  692.           /* Flag that we are processing base and member initializers.  */
  693.           current_vtable_decl = error_mark_node;
  694.  
  695.           if (DECL_CONSTRUCTOR_P (current_function_decl))
  696.             {
  697.               /* Make a contour for the initializer list.  */
  698.               pushlevel (0);
  699.               clear_last_expr ();
  700.               expand_start_bindings (0);
  701.             }
  702.           else if (current_class_type == NULL_TREE)
  703.             error ("base initializers not allowed for non-member functions");
  704.           else if (! DECL_CONSTRUCTOR_P (current_function_decl))
  705.             error ("only constructors take base initializers");
  706.         }
  707.     ;
  708.  
  709. member_init_list:
  710.       /* empty */
  711.         { $$ = 0; }
  712.     | member_init
  713.         { $$ = 1; }
  714.     | member_init_list ',' member_init
  715.     | member_init_list error
  716.     ;
  717.  
  718. member_init: '(' nonnull_exprlist ')'
  719.         {
  720.           if (current_class_name && !flag_traditional)
  721.             pedwarn ("anachronistic old style base class initializer");
  722.           expand_member_init (C_C_D, NULL_TREE, $2);
  723.         }
  724.     | LEFT_RIGHT
  725.         {
  726.           if (current_class_name && !flag_traditional)
  727.             pedwarn ("anachronistic old style base class initializer");
  728.           expand_member_init (C_C_D, NULL_TREE, void_type_node);
  729.         }
  730.     | notype_identifier '(' nonnull_exprlist ')'
  731.         { expand_member_init (C_C_D, $<ttype>$, $3); }
  732.     | notype_identifier LEFT_RIGHT
  733.         { expand_member_init (C_C_D, $<ttype>$, void_type_node); }
  734.     | complete_type_name '(' nonnull_exprlist ')'
  735.         { expand_member_init (C_C_D, $<ttype>$, $3); }
  736.     | complete_type_name LEFT_RIGHT
  737.         { expand_member_init (C_C_D, $<ttype>$, void_type_node); }
  738.     /* GNU extension */
  739.     | notype_qualified_id '(' nonnull_exprlist ')'
  740.         {
  741.           do_member_init (OP0 ($1), OP1 ($1), $3);
  742.         }
  743.     | notype_qualified_id LEFT_RIGHT
  744.         {
  745.           do_member_init (OP0 ($1), OP1 ($1), void_type_node);
  746.         }
  747.     ;
  748.  
  749. identifier:
  750.       IDENTIFIER
  751.     | TYPENAME
  752.     | PTYPENAME
  753.     ;
  754.  
  755. notype_identifier:
  756.       IDENTIFIER
  757.     | PTYPENAME %prec EMPTY
  758.     ;
  759.  
  760. identifier_defn:
  761.       IDENTIFIER_DEFN
  762.     | TYPENAME_DEFN
  763.     | PTYPENAME_DEFN
  764.     ;
  765.  
  766. explicit_instantiation:
  767.       TEMPLATE specialization template_instantiation
  768.         { do_type_instantiation ($3 ? $3 : $2, NULL_TREE); }
  769.     | TEMPLATE typed_declspecs declarator
  770.         { do_function_instantiation ($2, $3, NULL_TREE); }
  771.     | SCSPEC TEMPLATE specialization template_instantiation
  772.         { do_type_instantiation ($4 ? $4 : $3, $1); }
  773.     | SCSPEC TEMPLATE typed_declspecs declarator
  774.         { do_function_instantiation ($3, $4, $1); }
  775.     ;
  776.  
  777. template_type:
  778.       template_type_name tmpl.2 template_instantiation
  779.         { if ($3) $$ = $3; }
  780.     ;
  781.  
  782. template_type_name:
  783.       PTYPENAME '<' template_arg_list '>'
  784.         { $$ = lookup_template_class ($$, $3, NULL_TREE); }
  785.     | TYPENAME  '<' template_arg_list '>'
  786.         { $$ = lookup_template_class ($$, $3, NULL_TREE); }
  787.     ;
  788.  
  789. tmpl.2: 
  790.       /* empty */ %prec EMPTY
  791.         { $$ = instantiate_class_template ($<ttype>0, 1); }
  792.     ;
  793.  
  794. template_arg_list:
  795.       template_arg
  796.         { $$ = build_tree_list (NULL_TREE, $$); }
  797.     | template_arg_list ',' template_arg
  798.         { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
  799.     ;
  800.  
  801. template_arg:
  802.       type_id
  803.         { $$ = groktypename ($$); }
  804.     | expr_no_commas  %prec UNARY
  805.     ;
  806.  
  807. template_instantiate_once:
  808.       PRE_PARSED_CLASS_DECL maybe_base_class_list
  809.         {
  810.           tree t, decl, tmpl;
  811.  
  812.           tmpl = TREE_PURPOSE (IDENTIFIER_TEMPLATE ($1));
  813.           t = xref_tag (DECL_TEMPLATE_INFO (tmpl)->aggr, $1, $2, 0);
  814.           set_current_level_tags_transparency (1);
  815.           my_friendly_assert (TREE_CODE (t) == RECORD_TYPE
  816.                       || TREE_CODE (t) == UNION_TYPE, 257);
  817.           $<ttype>$ = t;
  818.  
  819.           /* Now, put a copy of the decl in global scope, to avoid
  820.              recursive expansion.  */
  821.           decl = IDENTIFIER_LOCAL_VALUE ($1);
  822.           if (!decl)
  823.             decl = IDENTIFIER_CLASS_VALUE ($1);
  824.           /* Now, put a copy of the decl in global scope, to avoid
  825.              recursive expansion.  */
  826.                   if (decl)
  827.                     {
  828.               /* Need to copy it to clear the chain pointer,
  829.              and need to get it into permanent storage.  */
  830.                       my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 258);
  831.               push_obstacks (&permanent_obstack, &permanent_obstack);
  832.                       decl = copy_node (decl);
  833.               if (DECL_LANG_SPECIFIC (decl))
  834.             copy_lang_decl (decl);
  835.               pop_obstacks ();
  836.               pushdecl_top_level (decl);
  837.             }
  838.           /* Kludge; see instantiate_class_template.  */
  839.           TYPE_BEING_DEFINED (t) = 0;
  840.         }
  841.       left_curly opt.component_decl_list '}'
  842.         {
  843.           tree t = finish_struct ($<ttype>3, $5, 0);
  844.  
  845.           pop_obstacks ();
  846.           end_template_instantiation ($1);
  847.  
  848.                   /* Now go after the methods & class data.  */
  849.                   instantiate_member_templates ($1);
  850.  
  851.           pop_tinst_level();
  852.  
  853.           CLASSTYPE_GOT_SEMICOLON (t) = 1;
  854.         }
  855.     ;
  856.  
  857. template_instantiation:
  858.           /* empty */
  859.                 { $$ = NULL_TREE; }
  860.         | template_instantiate_once
  861.                 { $$ = $1; }
  862.         ;
  863.  
  864. template_instantiate_some:
  865.           /* empty */
  866.                 { $$ = NULL_TREE; /* never used from here... */}
  867.         | template_instantiate_once template_instantiate_some
  868.                 { $$ = $1; /*???*/ }
  869.         ;
  870.  
  871. unop:     '-'
  872.         { $$ = NEGATE_EXPR; }
  873.     | '+'
  874.         { $$ = CONVERT_EXPR; }
  875.     | PLUSPLUS
  876.         { $$ = PREINCREMENT_EXPR; }
  877.     | MINUSMINUS
  878.         { $$ = PREDECREMENT_EXPR; }
  879.     | '!'
  880.         { $$ = TRUTH_NOT_EXPR; }
  881.     ;
  882.  
  883. expr:      nontrivial_exprlist
  884.         { $$ = build_x_compound_expr ($$); }
  885.     | expr_no_commas
  886.     ;
  887.  
  888. paren_expr_or_null:
  889.     LEFT_RIGHT
  890.         { error ("ANSI C++ forbids an empty condition for `%s'",
  891.              cond_stmt_keyword);
  892.           $$ = integer_zero_node; }
  893.     | '(' expr ')'
  894.         { $$ = $2; }
  895.     ;
  896.  
  897. paren_cond_or_null:
  898.     LEFT_RIGHT
  899.         { error ("ANSI C++ forbids an empty condition for `%s'",
  900.              cond_stmt_keyword);
  901.           $$ = integer_zero_node; }
  902.     | '(' condition ')'
  903.         { $$ = $2; }
  904.     ;
  905.  
  906. xcond:
  907.     /* empty */
  908.         { $$ = NULL_TREE; }
  909.     | condition
  910.     | error
  911.         { $$ = NULL_TREE; }
  912.     ;
  913.  
  914. condition:
  915.     type_specifier_seq declarator maybe_raises maybeasm maybe_attribute '='
  916.         { {
  917.           tree d;
  918.           for (d = getdecls (); d; d = TREE_CHAIN (d))
  919.             if (TREE_CODE (d) == TYPE_DECL) {
  920.               tree s = TREE_TYPE (d);
  921.               if (TREE_CODE (s) == RECORD_TYPE)
  922.             cp_error ("definition of class `%T' in condition", s);
  923.               else if (TREE_CODE (s) == ENUMERAL_TYPE)
  924.             cp_error ("definition of enum `%T' in condition", s);
  925.             }
  926.           }
  927.           current_declspecs = $1;
  928.           $<itype>6 = suspend_momentary ();
  929.           $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3);
  930.           cplus_decl_attributes ($<ttype>$, $5);
  931.         }
  932.     init
  933.         { 
  934.           finish_decl ($<ttype>7, $8, $5, 0);
  935.           resume_momentary ($<itype>6);
  936.           $$ = $<ttype>7; 
  937.           if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
  938.             cp_error ("definition of array `%#D' in condition", $$); 
  939.         }
  940.     | expr
  941.     ;
  942.  
  943. already_scoped_stmt:
  944.       '{' '}'
  945.         { finish_stmt (); }
  946.     | '{' maybe_label_decls stmts '}'
  947.         { finish_stmt (); }
  948.     | '{' maybe_label_decls error '}'
  949.         { finish_stmt (); }
  950.     | simple_stmt
  951.     ;
  952.  
  953.  
  954. nontrivial_exprlist:
  955.       expr_no_commas ',' expr_no_commas
  956.         { $$ = tree_cons (NULL_TREE, $$, 
  957.                           build_tree_list (NULL_TREE, $3)); }
  958.     | expr_no_commas ',' error
  959.         { $$ = tree_cons (NULL_TREE, $$, 
  960.                           build_tree_list (NULL_TREE, error_mark_node)); }
  961.     | nontrivial_exprlist ',' expr_no_commas
  962.         { chainon ($$, build_tree_list (NULL_TREE, $3)); }
  963.     | nontrivial_exprlist ',' error
  964.         { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
  965.     ;
  966.  
  967. nonnull_exprlist:
  968.       expr_no_commas
  969.         { $$ = build_tree_list (NULL_TREE, $$); }
  970.     | nontrivial_exprlist
  971.     ;
  972.  
  973. unary_expr:
  974.       primary %prec UNARY
  975.         {
  976. #if 0
  977.           if (TREE_CODE ($$) == TYPE_EXPR)
  978.             $$ = build_component_type_expr (C_C_D, $$, NULL_TREE, 1);
  979. #endif
  980.         }
  981.     /* __extension__ turns off -pedantic for following primary.  */
  982.     | EXTENSION
  983.         { $<itype>1 = pedantic;
  984.           pedantic = 0; }
  985.       cast_expr      %prec UNARY
  986.         { $$ = $3;
  987.           pedantic = $<itype>1; }
  988.     | '*' cast_expr   %prec UNARY
  989.         { $$ = build_x_indirect_ref ($2, "unary *"); }
  990.     | '&' cast_expr   %prec UNARY
  991.         { $$ = build_x_unary_op (ADDR_EXPR, $2); }
  992.     | '~' cast_expr
  993.         { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
  994.     | unop cast_expr  %prec UNARY
  995.         { $$ = build_x_unary_op ($1, $2);
  996.           if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST)
  997.             TREE_NEGATED_INT ($$) = 1;
  998.           overflow_warning ($$);
  999.         }
  1000.     /* Refer to the address of a label as a pointer.  */
  1001.     | ANDAND identifier
  1002.         { tree label = lookup_label ($2);
  1003.           if (label == NULL_TREE)
  1004.             $$ = null_pointer_node;
  1005.           else
  1006.             {
  1007.               TREE_USED (label) = 1;
  1008.               $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  1009.               TREE_CONSTANT ($$) = 1;
  1010.             }
  1011.         }
  1012.     | SIZEOF unary_expr  %prec UNARY
  1013.         { if (TREE_CODE ($2) == COMPONENT_REF
  1014.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  1015.             error ("sizeof applied to a bit-field");
  1016.           /* ANSI says arrays and functions are converted inside comma.
  1017.              But we can't really convert them in build_compound_expr
  1018.              because that would break commas in lvalues.
  1019.              So do the conversion here if operand was a comma.  */
  1020.           if (TREE_CODE ($2) == COMPOUND_EXPR
  1021.               && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE
  1022.               || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE))
  1023.             $2 = default_conversion ($2);
  1024.           else if (TREE_CODE ($2) == TREE_LIST)
  1025.                 {
  1026.               tree t = TREE_VALUE ($2);
  1027.               if (t != NULL_TREE
  1028.               && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
  1029.             pedwarn ("ANSI C++ forbids using sizeof() on a function");
  1030.             }
  1031.           $$ = c_sizeof (TREE_TYPE ($2)); }
  1032.     | SIZEOF '(' type_id ')'  %prec HYPERUNARY
  1033.         { $$ = c_sizeof (groktypename ($3)); }
  1034.     | ALIGNOF unary_expr  %prec UNARY
  1035.         { $$ = grok_alignof ($2); }
  1036.     | ALIGNOF '(' type_id ')'  %prec HYPERUNARY
  1037.         { $$ = c_alignof (groktypename ($3)); }
  1038.  
  1039.     /* The %prec EMPTY's here are required by the = init initializer
  1040.        syntax extension; see below.  */
  1041.     | new new_type_id %prec EMPTY
  1042.         { $$ = build_new (NULL_TREE, $2, NULL_TREE, $1); }
  1043.     | new new_type_id new_initializer
  1044.         { $$ = build_new (NULL_TREE, $2, $3, $1); }
  1045.     | new new_placement new_type_id %prec EMPTY
  1046.         { $$ = build_new ($2, $3, NULL_TREE, $1); }
  1047.     | new new_placement new_type_id new_initializer
  1048.         { $$ = build_new ($2, $3, $4, $1); }
  1049.     | new '(' type_id ')' %prec EMPTY
  1050.         { $$ = build_new (NULL_TREE, groktypename($3),
  1051.                   NULL_TREE, $1); }
  1052.     | new '(' type_id ')' new_initializer
  1053.         { $$ = build_new (NULL_TREE, groktypename($3), $5, $1); }
  1054.     | new new_placement '(' type_id ')' %prec EMPTY
  1055.         { $$ = build_new ($2, groktypename($4), NULL_TREE, $1); }
  1056.     | new new_placement '(' type_id ')' new_initializer
  1057.         { $$ = build_new ($2, groktypename($4), $6, $1); }
  1058.  
  1059.     | delete cast_expr  %prec UNARY
  1060.         { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
  1061.     | delete '[' ']' cast_expr  %prec UNARY
  1062.         { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
  1063.           if (yychar == YYEMPTY)
  1064.             yychar = YYLEX; }
  1065.     | delete '[' expr ']' cast_expr %prec UNARY
  1066.         { $$ = delete_sanity ($5, $3, 2, $1);
  1067.           if (yychar == YYEMPTY)
  1068.             yychar = YYLEX; }
  1069.     ;
  1070.  
  1071. new_placement:
  1072.       '(' nonnull_exprlist ')'
  1073.         { $$ = $2; }
  1074.     | '{' nonnull_exprlist '}'
  1075.         {
  1076.           $$ = $2; 
  1077.           pedwarn ("old style placement syntax, use () instead");
  1078.         }
  1079.     ;
  1080.  
  1081. new_initializer:
  1082.       '(' nonnull_exprlist ')'
  1083.         { $$ = $2; }
  1084.     | LEFT_RIGHT
  1085.         { $$ = NULL_TREE; }
  1086.     | '(' typespec ')'
  1087.         {
  1088.           cp_error ("`%T' is not a valid expression", $2);
  1089.           $$ = error_mark_node;
  1090.         }
  1091.     /* GNU extension so people can use initializer lists.  Note that
  1092.        this alters the meaning of `new int = 1', which was previously
  1093.        syntactically valid but semantically invalid.  */
  1094.     | '=' init
  1095.         {
  1096.           if (flag_ansi)
  1097.             pedwarn ("ANSI C++ forbids initialization of new expression with `='");
  1098.           $$ = $2;
  1099.         }
  1100.     ;
  1101.  
  1102. /* This is necessary to postpone reduction of `int ((int)(int)(int))'.  */
  1103. regcast_or_absdcl:
  1104.       '(' type_id ')' %prec EMPTY
  1105.         { $2 = tree_cons (NULL_TREE, $2, void_list_node);
  1106.           TREE_PARMLIST ($2) = 1;
  1107.           $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, 
  1108.                      NULL_TREE); }
  1109.     | regcast_or_absdcl '(' type_id ')' %prec EMPTY
  1110.         { $3 = tree_cons (NULL_TREE, $3, void_list_node);
  1111.           TREE_PARMLIST ($3) = 1;
  1112.           $$ = build_parse_node (CALL_EXPR, $$, $3, NULL_TREE); }
  1113.     ;
  1114.  
  1115. cast_expr:
  1116.       sub_cast_expr
  1117.     | regcast_or_absdcl sub_cast_expr  %prec UNARY
  1118.         { $$ = reparse_absdcl_as_casts ($$, $2); }
  1119.     | regcast_or_absdcl '{' initlist maybecomma '}'  %prec UNARY
  1120.         { 
  1121.           tree init = build_nt (CONSTRUCTOR, NULL_TREE,
  1122.                     nreverse ($3)); 
  1123.           if (flag_ansi)
  1124.             pedwarn ("ANSI C++ forbids constructor-expressions");
  1125.           /* Indicate that this was a GNU C constructor expression.  */
  1126.           TREE_HAS_CONSTRUCTOR (init) = 1;
  1127.  
  1128.           $$ = reparse_absdcl_as_casts ($$, init);
  1129.         }
  1130.     ;
  1131.  
  1132. sub_cast_expr:
  1133.       unary_expr
  1134.     | HEADOF '(' expr ')'
  1135.         { $$ = build_headof ($3); }
  1136.     | CLASSOF '(' expr ')'
  1137.         { $$ = build_classof ($3); }
  1138.     | CLASSOF '(' TYPENAME ')'
  1139.         { if (is_aggr_typedef ($3, 1))
  1140.             {
  1141.               tree type = IDENTIFIER_TYPE_VALUE ($3);
  1142.               if (! IS_SIGNATURE(type))
  1143.             $$ = CLASSTYPE_DOSSIER (type);
  1144.               else
  1145.             {
  1146.               sorry ("signature name as argument of `classof'");
  1147.               $$ = error_mark_node;
  1148.             }
  1149.             }
  1150.           else
  1151.             $$ = error_mark_node;
  1152.         }
  1153.     ;
  1154.  
  1155. expr_no_commas:
  1156.       cast_expr
  1157.     /* Handle general members.  */
  1158.     | expr_no_commas POINTSAT_STAR expr_no_commas
  1159.         { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
  1160.     | expr_no_commas DOT_STAR expr_no_commas
  1161.         { $$ = build_m_component_ref ($$, $3); }
  1162.     | expr_no_commas '+' expr_no_commas
  1163.         { $$ = build_x_binary_op ($2, $$, $3); }
  1164.     | expr_no_commas '-' expr_no_commas
  1165.         { $$ = build_x_binary_op ($2, $$, $3); }
  1166.     | expr_no_commas '*' expr_no_commas
  1167.         { $$ = build_x_binary_op ($2, $$, $3); }
  1168.     | expr_no_commas '/' expr_no_commas
  1169.         { $$ = build_x_binary_op ($2, $$, $3); }
  1170.     | expr_no_commas '%' expr_no_commas
  1171.         { $$ = build_x_binary_op ($2, $$, $3); }
  1172.     | expr_no_commas LSHIFT expr_no_commas
  1173.         { $$ = build_x_binary_op ($2, $$, $3); }
  1174.     | expr_no_commas RSHIFT expr_no_commas
  1175.         { $$ = build_x_binary_op ($2, $$, $3); }
  1176.     | expr_no_commas ARITHCOMPARE expr_no_commas
  1177.         { $$ = build_x_binary_op ($2, $$, $3); }
  1178.     | expr_no_commas '<' expr_no_commas
  1179.         { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
  1180.     | expr_no_commas '>' expr_no_commas
  1181.         { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
  1182.     | expr_no_commas EQCOMPARE expr_no_commas
  1183.         { $$ = build_x_binary_op ($2, $$, $3); }
  1184.     | expr_no_commas MIN_MAX expr_no_commas
  1185.         { $$ = build_x_binary_op ($2, $$, $3); }
  1186.     | expr_no_commas '&' expr_no_commas
  1187.         { $$ = build_x_binary_op ($2, $$, $3); }
  1188.     | expr_no_commas '|' expr_no_commas
  1189.         { $$ = build_x_binary_op ($2, $$, $3); }
  1190.     | expr_no_commas '^' expr_no_commas
  1191.         { $$ = build_x_binary_op ($2, $$, $3); }
  1192.     | expr_no_commas ANDAND expr_no_commas
  1193.         { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
  1194.     | expr_no_commas OROR expr_no_commas
  1195.         { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
  1196.     | expr_no_commas '?' xexpr ':' expr_no_commas
  1197.         { $$ = build_x_conditional_expr ($$, $3, $5); }
  1198.     | expr_no_commas '=' expr_no_commas
  1199.         { $$ = build_modify_expr ($$, NOP_EXPR, $3); }
  1200.     | expr_no_commas ASSIGN expr_no_commas
  1201.         { register tree rval;
  1202.           if ((rval = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, $$, $3,
  1203.                          make_node ($2))))
  1204.             $$ = rval;
  1205.           else
  1206.             $$ = build_modify_expr ($$, $2, $3); }
  1207.     | THROW
  1208.         { $$ = build_throw (NULL_TREE); }
  1209.     | THROW expr_no_commas
  1210.         { $$ = build_throw ($2); }
  1211. /* These extensions are not defined.  The second arg to build_m_component_ref
  1212.    is old, build_m_component_ref now does an implicit
  1213.    build_indirect_ref (x, NULL_PTR) on the second argument.
  1214.     | object '&' expr_no_commas   %prec UNARY
  1215.         { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
  1216.     | object unop expr_no_commas  %prec UNARY
  1217.         { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
  1218.     | object '(' type_id ')' expr_no_commas  %prec UNARY
  1219.         { tree type = groktypename ($3);
  1220.           $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
  1221.     | object primary_no_id  %prec UNARY
  1222.         { $$ = build_m_component_ref ($$, $2); }
  1223. */
  1224.     ;
  1225.  
  1226. notype_unqualified_id:
  1227.       '~' see_typename identifier
  1228.         { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
  1229.     | operator_name
  1230.     | IDENTIFIER
  1231.     | PTYPENAME %prec EMPTY
  1232.     ;
  1233.  
  1234. unqualified_id:
  1235.       notype_unqualified_id
  1236.     | TYPENAME
  1237.     ;
  1238.  
  1239. expr_or_declarator:
  1240.       notype_unqualified_id
  1241.     | notype_qualified_id
  1242.     | '*' expr_or_declarator %prec UNARY
  1243.         { $$ = build_parse_node (INDIRECT_REF, $2); }
  1244.     | '&' expr_or_declarator %prec UNARY
  1245.         { $$ = build_parse_node (ADDR_EXPR, $2); }
  1246.     ;
  1247.  
  1248. direct_notype_declarator:
  1249.       complex_direct_notype_declarator
  1250.     | notype_unqualified_id
  1251.     | notype_qualified_id
  1252.         { push_nested_class (TREE_TYPE (OP0 ($$)), 3);
  1253.           TREE_COMPLEXITY ($$) = current_class_depth; }
  1254.     ;
  1255.  
  1256. primary:
  1257.       notype_unqualified_id
  1258.         {
  1259.           if (TREE_CODE ($$) == BIT_NOT_EXPR)
  1260.             $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0));
  1261.           else if (IDENTIFIER_OPNAME_P ($$))
  1262.             {
  1263.               tree op = $$;
  1264.               $$ = lookup_name (op, 0);
  1265.               if ($$ == NULL_TREE)
  1266.             {
  1267.               if (op != ansi_opname[ERROR_MARK])
  1268.                 error ("operator %s not defined",
  1269.                    operator_name_string (op));
  1270.               $$ = error_mark_node;
  1271.             }
  1272.             }
  1273.           else
  1274.             $$ = do_identifier ($$);
  1275.         }        
  1276.     | CONSTANT
  1277.     | boolean.literal
  1278.     | string
  1279.         { $$ = combine_strings ($$); }
  1280.     | '(' expr ')'
  1281.         { $$ = $2; }
  1282.     | '(' error ')'
  1283.         { $$ = error_mark_node; }
  1284.     | '('
  1285.         { if (current_function_decl == 0)
  1286.             {
  1287.               error ("braced-group within expression allowed only inside a function");
  1288.               YYERROR;
  1289.             }
  1290.           keep_next_level ();
  1291.           $<ttype>$ = expand_start_stmt_expr (); }
  1292.       compstmt ')'
  1293.         { tree rtl_exp;
  1294.           if (flag_ansi)
  1295.             pedwarn ("ANSI C++ forbids braced-groups within expressions");
  1296.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  1297.           /* The statements have side effects, so the group does.  */
  1298.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  1299.  
  1300.           if (TREE_CODE ($3) == BLOCK)
  1301.             {
  1302.               /* Make a BIND_EXPR for the BLOCK already made.  */
  1303.               $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  1304.                   NULL_TREE, rtl_exp, $3);
  1305.               /* Remove the block from the tree at this point.
  1306.              It gets put back at the proper place
  1307.              when the BIND_EXPR is expanded.  */
  1308.               delete_block ($3);
  1309.             }
  1310.           else
  1311.             $$ = $3;
  1312.         }
  1313.     | primary '(' nonnull_exprlist ')'
  1314.                 { /* [eichin:19911016.1902EST] */
  1315.                   $<ttype>$ = build_x_function_call ($1, $3, current_class_decl); 
  1316.                   /* here we instantiate_class_template as needed... */
  1317.                   do_pending_templates ();
  1318.                 } template_instantiate_some {
  1319.                   if (TREE_CODE ($<ttype>5) == CALL_EXPR
  1320.                       && TREE_TYPE ($<ttype>5) != void_type_node)
  1321.                 $$ = require_complete_type ($<ttype>5);
  1322.                   else
  1323.                     $$ = $<ttype>5;
  1324.                 }
  1325.     | primary LEFT_RIGHT
  1326.                 {
  1327.           $$ = build_x_function_call ($$, NULL_TREE, current_class_decl);
  1328.           if (TREE_CODE ($$) == CALL_EXPR
  1329.               && TREE_TYPE ($$) != void_type_node)
  1330.             $$ = require_complete_type ($$);
  1331.                 }
  1332.     | primary '[' expr ']'
  1333.         { $$ = grok_array_decl ($$, $3); }
  1334.     | primary PLUSPLUS
  1335.         { /* If we get an OFFSET_REF, turn it into what it really
  1336.              means (e.g., a COMPONENT_REF).  This way if we've got,
  1337.              say, a reference to a static member that's being operated
  1338.              on, we don't end up trying to find a member operator for
  1339.              the class it's in.  */
  1340.           if (TREE_CODE ($$) == OFFSET_REF)
  1341.             $$ = resolve_offset_ref ($$);
  1342.           $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
  1343.     | primary MINUSMINUS
  1344.         { if (TREE_CODE ($$) == OFFSET_REF)
  1345.             $$ = resolve_offset_ref ($$);
  1346.           $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
  1347.     /* C++ extensions */
  1348.     | THIS
  1349.         { if (current_class_decl)
  1350.             {
  1351. #ifdef WARNING_ABOUT_CCD
  1352.               TREE_USED (current_class_decl) = 1;
  1353. #endif
  1354.               $$ = current_class_decl;
  1355.             }
  1356.           else if (current_function_decl
  1357.                && DECL_STATIC_FUNCTION_P (current_function_decl))
  1358.             {
  1359.               error ("`this' is unavailable for static member functions");
  1360.               $$ = error_mark_node;
  1361.             }
  1362.           else
  1363.             {
  1364.               if (current_function_decl)
  1365.             error ("invalid use of `this' in non-member function");
  1366.               else
  1367.             error ("invalid use of `this' at top level");
  1368.               $$ = error_mark_node;
  1369.             }
  1370.         }
  1371.     | TYPE_QUAL '(' nonnull_exprlist ')'
  1372.         {
  1373.           tree type;
  1374.           tree id = $$;
  1375.  
  1376.           /* This is a C cast in C++'s `functional' notation.  */
  1377.           if ($3 == error_mark_node)
  1378.             {
  1379.               $$ = error_mark_node;
  1380.               break;
  1381.             }
  1382. #if 0
  1383.           if ($3 == NULL_TREE)
  1384.             {
  1385.               error ("cannot cast null list to type `%s'",
  1386.                      IDENTIFIER_POINTER (TYPE_NAME (id)));
  1387.               $$ = error_mark_node;
  1388.               break;
  1389.             }
  1390. #endif
  1391. #if 0
  1392.           /* type is not set! (mrs) */
  1393.           if (type == error_mark_node)
  1394.             $$ = error_mark_node;
  1395.           else
  1396. #endif
  1397.             {
  1398.               if (id == ridpointers[(int) RID_CONST])
  1399.                 type = build_type_variant (integer_type_node, 1, 0);
  1400.               else if (id == ridpointers[(int) RID_VOLATILE])
  1401.                 type = build_type_variant (integer_type_node, 0, 1);
  1402. #if 0
  1403.               /* should not be able to get here (mrs) */
  1404.               else if (id == ridpointers[(int) RID_FRIEND])
  1405.                 {
  1406.                   error ("cannot cast expression to `friend' type");
  1407.                   $$ = error_mark_node;
  1408.                   break;
  1409.                 }
  1410. #endif
  1411.               else my_friendly_abort (79);
  1412.               $$ = build_c_cast (type, build_compound_expr ($3));
  1413.             }
  1414.         }
  1415.     | functional_cast
  1416.     | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
  1417.         { tree type = groktypename ($3);
  1418.           $$ = build_dynamic_cast (type, $6); }
  1419.     | STATIC_CAST '<' type_id '>' '(' expr ')'
  1420.         { tree type = groktypename ($3);
  1421.           $$ = build_static_cast (type, $6); }
  1422.     | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
  1423.         { tree type = groktypename ($3);
  1424.           $$ = build_reinterpret_cast (type, $6); }
  1425.     | CONST_CAST '<' type_id '>' '(' expr ')'
  1426.         { tree type = groktypename ($3);
  1427.           $$ = build_const_cast (type, $6); }
  1428.     | TYPEID '(' expr ')'
  1429.         { $$ = build_typeid ($3); }
  1430.     | TYPEID '(' type_id ')'
  1431.         { tree type = groktypename ($3);
  1432.           $$ = get_typeid (type); }
  1433.     | global_scope IDENTIFIER
  1434.         {
  1435.         do_scoped_id:
  1436.           $$ = IDENTIFIER_GLOBAL_VALUE ($2);
  1437.           if (yychar == YYEMPTY)
  1438.             yychar = YYLEX;
  1439.           if (! $$)
  1440.             {
  1441.               if (yychar == '(' || yychar == LEFT_RIGHT)
  1442.             $$ = implicitly_declare ($2);
  1443.               else
  1444.             {
  1445.               if (IDENTIFIER_GLOBAL_VALUE ($2) != error_mark_node)
  1446.                 error ("undeclared variable `%s' (first use here)",
  1447.                    IDENTIFIER_POINTER ($2));
  1448.               $$ = error_mark_node;
  1449.               /* Prevent repeated error messages.  */
  1450.               IDENTIFIER_GLOBAL_VALUE ($2) = error_mark_node;
  1451.             }
  1452.             }
  1453.           else
  1454.             {
  1455.               if (TREE_CODE ($$) == ADDR_EXPR)
  1456.             assemble_external (TREE_OPERAND ($$, 0));
  1457.               else
  1458.             assemble_external ($$);
  1459.               TREE_USED ($$) = 1;
  1460.             }
  1461.           if (TREE_CODE ($$) == CONST_DECL)
  1462.             {
  1463.               /* XXX CHS - should we set TREE_USED of the constant? */
  1464.               $$ = DECL_INITIAL ($$);
  1465.               /* This is to prevent an enum whose value is 0
  1466.              from being considered a null pointer constant.  */
  1467.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  1468.               TREE_CONSTANT ($$) = 1;
  1469.             }
  1470.  
  1471.         }
  1472.     | global_scope operator_name
  1473.         {
  1474.           got_scope = NULL_TREE;
  1475.           if (TREE_CODE ($2) == IDENTIFIER_NODE)
  1476.             goto do_scoped_id;
  1477.           $$ = $2;
  1478.         }
  1479.     | overqualified_id %prec HYPERUNARY
  1480.         { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
  1481.     | overqualified_id '(' nonnull_exprlist ')'
  1482.         { $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
  1483.     | overqualified_id LEFT_RIGHT
  1484.         { $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
  1485.     | object unqualified_id  %prec UNARY
  1486.         { $$ = build_component_ref ($$, $2, NULL_TREE, 1); }
  1487.     | object qualified_id %prec UNARY
  1488.         { $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
  1489.     | object unqualified_id '(' nonnull_exprlist ')'
  1490.         {
  1491. #if 0
  1492.           /* This is a future direction of this code, but because
  1493.              build_x_function_call cannot always undo what is done
  1494.              in build_component_ref entirely yet, we cannot do this. */
  1495.           $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, $$);
  1496.           if (TREE_CODE ($$) == CALL_EXPR
  1497.               && TREE_TYPE ($$) != void_type_node)
  1498.             $$ = require_complete_type ($$);
  1499. #else
  1500.           $$ = build_method_call ($$, $2, $4, NULL_TREE,
  1501.                       (LOOKUP_NORMAL|LOOKUP_AGGR));
  1502. #endif
  1503.         }
  1504.     | object unqualified_id LEFT_RIGHT
  1505.         {
  1506. #if 0
  1507.           /* This is a future direction of this code, but because
  1508.              build_x_function_call cannot always undo what is done
  1509.              in build_component_ref entirely yet, we cannot do this. */
  1510.           $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, $$);
  1511.           if (TREE_CODE ($$) == CALL_EXPR
  1512.               && TREE_TYPE ($$) != void_type_node)
  1513.             $$ = require_complete_type ($$);
  1514. #else
  1515.           $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
  1516.                       (LOOKUP_NORMAL|LOOKUP_AGGR));
  1517. #endif
  1518.         }
  1519.     | object qualified_id '(' nonnull_exprlist ')'
  1520.         {
  1521.           if (IS_SIGNATURE (IDENTIFIER_TYPE_VALUE (OP0 ($2))))
  1522.             {
  1523.               warning ("signature name in scope resolution ignored");
  1524.               $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
  1525.                           (LOOKUP_NORMAL|LOOKUP_AGGR));
  1526.             }
  1527.           else
  1528.             $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
  1529.         }
  1530.     | object qualified_id LEFT_RIGHT
  1531.         {
  1532.           if (IS_SIGNATURE (IDENTIFIER_TYPE_VALUE (OP0 ($2))))
  1533.             {
  1534.               warning ("signature name in scope resolution ignored");
  1535.               $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
  1536.                           (LOOKUP_NORMAL|LOOKUP_AGGR));
  1537.             }
  1538.           else
  1539.             $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
  1540.         }
  1541.     /* p->int::~int() is valid -- 12.4 */
  1542.     | object '~' TYPESPEC LEFT_RIGHT
  1543.         { 
  1544.           if (TREE_CODE (TREE_TYPE ($1)) 
  1545.               != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3))))
  1546.             cp_error ("`%E' is not of type `%T'", $1, $3);
  1547.           $$ = void_zero_node;
  1548.         }
  1549.     | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
  1550.         { 
  1551.           if ($2 != $5)
  1552.             cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
  1553.           if (TREE_CODE (TREE_TYPE ($1))
  1554.               != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
  1555.             cp_error ("`%E' is not of type `%T'", $1, $2);
  1556.           $$ = void_zero_node; 
  1557.         }
  1558.     ;
  1559.  
  1560. /* Not needed for now.
  1561.  
  1562. primary_no_id:
  1563.       '(' expr ')'
  1564.         { $$ = $2; }
  1565.     | '(' error ')'
  1566.         { $$ = error_mark_node; }
  1567.     | '('
  1568.         { if (current_function_decl == 0)
  1569.             {
  1570.               error ("braced-group within expression allowed only inside a function");
  1571.               YYERROR;
  1572.             }
  1573.           $<ttype>$ = expand_start_stmt_expr (); }
  1574.       compstmt ')'
  1575.         { if (flag_ansi)
  1576.             pedwarn ("ANSI C++ forbids braced-groups within expressions");
  1577.           $$ = expand_end_stmt_expr ($<ttype>2); }
  1578.     | primary_no_id '(' nonnull_exprlist ')'
  1579.         { $$ = build_x_function_call ($$, $3, current_class_decl); }
  1580.     | primary_no_id LEFT_RIGHT
  1581.         { $$ = build_x_function_call ($$, NULL_TREE, current_class_decl); }
  1582.     | primary_no_id '[' expr ']'
  1583.         { goto do_array; }
  1584.     | primary_no_id PLUSPLUS
  1585.         { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
  1586.     | primary_no_id MINUSMINUS
  1587.         { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
  1588.     | SCOPE IDENTIFIER
  1589.         { goto do_scoped_id; }
  1590.     | SCOPE operator_name
  1591.         { if (TREE_CODE ($2) == IDENTIFIER_NODE)
  1592.             goto do_scoped_id;
  1593.           goto do_scoped_operator;
  1594.         }
  1595.     ;
  1596. */
  1597.  
  1598. new:      NEW
  1599.         { $$ = 0; }
  1600.     | global_scope NEW
  1601.         { got_scope = NULL_TREE; $$ = 1; }
  1602.     ;
  1603.  
  1604. delete:      DELETE
  1605.         { $$ = 0; }
  1606.     | global_scope delete
  1607.         { got_scope = NULL_TREE; $$ = 1; }
  1608.     ;
  1609.  
  1610. boolean.literal:
  1611.       CXX_TRUE
  1612.         { $$ = true_node; }
  1613.     | CXX_FALSE
  1614.         { $$ = false_node; }
  1615.     ;
  1616.  
  1617. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  1618. string:
  1619.       STRING
  1620.     | string STRING
  1621.         { $$ = chainon ($$, $2); }
  1622.     ;
  1623.  
  1624. nodecls:
  1625.       /* empty */
  1626.         {
  1627.           if (! current_function_parms_stored)
  1628.             store_parm_decls ();
  1629.           setup_vtbl_ptr ();
  1630.           /* Always keep the BLOCK node associated with the outermost
  1631.              pair of curley braces of a function.  These are needed
  1632.              for correct operation of dwarfout.c.  */
  1633.           keep_next_level ();
  1634.         }
  1635.     ;
  1636.  
  1637. object:      primary '.'
  1638.     | primary POINTSAT
  1639.         {
  1640.           $$ = build_x_arrow ($$);
  1641.         }
  1642.     ;
  1643.  
  1644. decl:
  1645.     /* Normal case: make this fast.  */
  1646.       typespec declarator ';'
  1647.         { tree d = get_decl_list ($1);
  1648.           int yes = suspend_momentary ();
  1649.           d = start_decl ($2, d, 0, NULL_TREE);
  1650.           finish_decl (d, NULL_TREE, NULL_TREE, 0);
  1651.           resume_momentary (yes);
  1652.           if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
  1653.             note_got_semicolon ($1);
  1654.         }
  1655.     | typed_declspecs declarator ';'
  1656.         { tree d = $1;
  1657.           int yes = suspend_momentary ();
  1658.           d = start_decl ($2, d, 0, NULL_TREE);
  1659.           finish_decl (d, NULL_TREE, NULL_TREE, 0);
  1660.           resume_momentary (yes);
  1661.           note_list_got_semicolon ($1);
  1662.         }
  1663.     | typespec initdecls ';'
  1664.         {
  1665.           resume_momentary ($2);
  1666.           if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
  1667.             note_got_semicolon ($1);
  1668.         }
  1669.     | typed_declspecs initdecls ';'
  1670.         {
  1671.           resume_momentary ($2);
  1672.           note_list_got_semicolon ($1);
  1673.         }
  1674.     | declmods notype_initdecls ';'
  1675.         { resume_momentary ($2); }
  1676.     | typed_declspecs ';'
  1677.         {
  1678.           shadow_tag ($1);
  1679.           note_list_got_semicolon ($1);
  1680.         }
  1681.     | declmods ';'
  1682.         { warning ("empty declaration"); }
  1683.     ;
  1684.  
  1685. /* Any kind of declarator (thus, all declarators allowed
  1686.    after an explicit typespec).  */
  1687.  
  1688. declarator:
  1689.       after_type_declarator %prec EMPTY
  1690.     | notype_declarator %prec EMPTY
  1691.     ;
  1692.  
  1693. /* This is necessary to postpone reduction of `int()()()()'.  */
  1694. fcast_or_absdcl:
  1695.       LEFT_RIGHT %prec EMPTY
  1696.         { $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (),
  1697.                      NULL_TREE); }
  1698.     | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
  1699.         { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), 
  1700.                      NULL_TREE); }
  1701.     ;
  1702.  
  1703. /* ANSI type-id (8.1) */
  1704. type_id:
  1705.       typed_typespecs absdcl
  1706.         { $$ = build_decl_list ($$, $2); }
  1707.     | nonempty_type_quals absdcl
  1708.         { $$ = build_decl_list ($$, $2); }
  1709.     | typespec absdcl
  1710.         { $$ = build_decl_list (get_decl_list ($$), $2); }
  1711.     | typed_typespecs %prec EMPTY
  1712.         { $$ = build_decl_list ($$, NULL_TREE); }
  1713.     | nonempty_type_quals %prec EMPTY
  1714.         { $$ = build_decl_list ($$, NULL_TREE); }
  1715.     ;
  1716.  
  1717. /* Declspecs which contain at least one type specifier or typedef name.
  1718.    (Just `const' or `volatile' is not enough.)
  1719.    A typedef'd name following these is taken as a name to be declared.  */
  1720.  
  1721. typed_declspecs:
  1722.       typed_typespecs %prec EMPTY
  1723.     | typed_declspecs1
  1724.  
  1725. typed_declspecs1:
  1726.       declmods typespec
  1727.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  1728.     | typespec reserved_declspecs    %prec HYPERUNARY
  1729.         { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
  1730.     | declmods typespec reserved_declspecs
  1731.         { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
  1732.     | declmods typespec reserved_typespecquals
  1733.         { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
  1734.     | declmods typespec reserved_typespecquals reserved_declspecs
  1735.         { $$ = decl_tree_cons (NULL_TREE, $2, 
  1736.                        chainon ($3, chainon ($4, $$))); }
  1737.     ;
  1738.  
  1739. reserved_declspecs:
  1740.       SCSPEC
  1741.         { if (extra_warnings)
  1742.             warning ("`%s' is not at beginning of declaration",
  1743.                  IDENTIFIER_POINTER ($$));
  1744.           $$ = build_decl_list (NULL_TREE, $$); }
  1745.     | reserved_declspecs typespecqual_reserved
  1746.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  1747.     | reserved_declspecs SCSPEC
  1748.         { if (extra_warnings)
  1749.             warning ("`%s' is not at beginning of declaration",
  1750.                  IDENTIFIER_POINTER ($2));
  1751.           $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  1752.     ;
  1753.  
  1754. /* List of just storage classes and type modifiers.
  1755.    A declaration can start with just this, but then it cannot be used
  1756.    to redeclare a typedef-name.  */
  1757.  
  1758. declmods:
  1759.       nonempty_type_quals %prec EMPTY
  1760.         { TREE_STATIC ($$) = 1; }
  1761.     | SCSPEC
  1762.         { $$ = IDENTIFIER_AS_LIST ($$); }
  1763.     | declmods TYPE_QUAL
  1764.         { $$ = decl_tree_cons (NULL_TREE, $2, $$);
  1765.           TREE_STATIC ($$) = 1; }
  1766.     | declmods SCSPEC
  1767.         { if (extra_warnings && TREE_STATIC ($$))
  1768.             warning ("`%s' is not at beginning of declaration",
  1769.                  IDENTIFIER_POINTER ($2));
  1770.           $$ = decl_tree_cons (NULL_TREE, $2, $$);
  1771.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  1772.     ;
  1773.  
  1774.  
  1775. /* Used instead of declspecs where storage classes are not allowed
  1776.    (that is, for typenames and structure components).
  1777.  
  1778.    C++ can takes storage classes for structure components.
  1779.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  1780.  
  1781. typed_typespecs:
  1782.       typespec  %prec EMPTY
  1783.         { $$ = get_decl_list ($$); }
  1784.     | nonempty_type_quals typespec
  1785.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  1786.     | typespec reserved_typespecquals
  1787.         { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
  1788.     | nonempty_type_quals typespec reserved_typespecquals
  1789.         { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
  1790.     ;
  1791.  
  1792. reserved_typespecquals:
  1793.       typespecqual_reserved
  1794.         { $$ = build_decl_list (NULL_TREE, $$); }
  1795.     | reserved_typespecquals typespecqual_reserved
  1796.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  1797.     ;
  1798.  
  1799. /* A typespec (but not a type qualifier).
  1800.    Once we have seen one of these in a declaration,
  1801.    if a typedef name appears then it is being redeclared.  */
  1802.  
  1803. typespec: structsp
  1804.     | TYPESPEC  %prec EMPTY
  1805.     | complete_type_name
  1806.     | TYPEOF '(' expr ')'
  1807.         { $$ = TREE_TYPE ($3);
  1808.           if (flag_ansi)
  1809.             pedwarn ("ANSI C++ forbids `typeof'"); }
  1810.     | TYPEOF '(' type_id ')'
  1811.         { $$ = groktypename ($3);
  1812.           if (flag_ansi)
  1813.             pedwarn ("ANSI C++ forbids `typeof'"); }
  1814.     | SIGOF '(' expr ')'
  1815.         { tree type = TREE_TYPE ($3);
  1816.  
  1817.           if (IS_AGGR_TYPE (type))
  1818.             {
  1819.               sorry ("sigof type specifier");
  1820.               $$ = type;
  1821.             }
  1822.           else
  1823.             {
  1824.               error ("`sigof' applied to non-aggregate expression");
  1825.               $$ = error_mark_node;
  1826.             }
  1827.         }
  1828.     | SIGOF '(' type_id ')'
  1829.         { tree type = groktypename ($3);
  1830.  
  1831.           if (IS_AGGR_TYPE (type))
  1832.             {
  1833.               sorry ("sigof type specifier");
  1834.               $$ = type;
  1835.             }
  1836.           else
  1837.             {
  1838.               error("`sigof' applied to non-aggregate type");
  1839.               $$ = error_mark_node;
  1840.             }
  1841.         }
  1842.     ;
  1843.  
  1844. /* A typespec that is a reserved word, or a type qualifier.  */
  1845.  
  1846. typespecqual_reserved: TYPESPEC
  1847.     | TYPE_QUAL
  1848.     | structsp
  1849.     ;
  1850.  
  1851. initdecls:
  1852.       initdcl0
  1853.     | initdecls ',' initdcl
  1854.     ;
  1855.  
  1856. notype_initdecls:
  1857.       notype_initdcl0
  1858.     | notype_initdecls ',' initdcl
  1859.     ;
  1860.  
  1861. nomods_initdecls:
  1862.       nomods_initdcl0
  1863.     | nomods_initdecls ',' initdcl
  1864.     ;
  1865.  
  1866. maybeasm:
  1867.       /* empty */
  1868.         { $$ = NULL_TREE; }
  1869.     | asm_keyword '(' string ')'
  1870.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
  1871.     ;
  1872.  
  1873. initdcl0:
  1874.       declarator maybe_raises maybeasm maybe_attribute '='
  1875.         { current_declspecs = $<ttype>0;
  1876.           if (TREE_CODE (current_declspecs) != TREE_LIST)
  1877.             current_declspecs = get_decl_list (current_declspecs);
  1878.           if (have_extern_spec && !used_extern_spec)
  1879.             {
  1880.               current_declspecs = decl_tree_cons
  1881.             (NULL_TREE, get_identifier ("extern"), 
  1882.              current_declspecs);
  1883.               used_extern_spec = 1;
  1884.             }
  1885.           $<itype>5 = suspend_momentary ();
  1886.           $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
  1887.           cplus_decl_attributes ($<ttype>$, $4); }
  1888.       init
  1889. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1890.         { finish_decl ($<ttype>6, $7, $3, 0);
  1891.           $$ = $<itype>5; }
  1892.     | declarator maybe_raises maybeasm maybe_attribute
  1893.         { tree d;
  1894.           current_declspecs = $<ttype>0;
  1895.           if (TREE_CODE (current_declspecs) != TREE_LIST)
  1896.             current_declspecs = get_decl_list (current_declspecs);
  1897.           if (have_extern_spec && !used_extern_spec)
  1898.             {
  1899.               current_declspecs = decl_tree_cons
  1900.             (NULL_TREE, get_identifier ("extern"), 
  1901.              current_declspecs);
  1902.               used_extern_spec = 1;
  1903.             }
  1904.           $$ = suspend_momentary ();
  1905.           d = start_decl ($<ttype>1, current_declspecs, 0, $2);
  1906.           cplus_decl_attributes (d, $4);
  1907.           finish_decl (d, NULL_TREE, $3, 0); }
  1908.     ;
  1909.  
  1910. initdcl:
  1911.       declarator maybe_raises maybeasm maybe_attribute '='
  1912.         { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
  1913.           cplus_decl_attributes ($<ttype>$, $4); }
  1914.       init
  1915. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1916.         { finish_decl ($<ttype>6, $7, $3, 0); }
  1917.     | declarator maybe_raises maybeasm maybe_attribute
  1918.         { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2);
  1919.           cplus_decl_attributes ($<ttype>$, $4);
  1920.           finish_decl ($<ttype>$, NULL_TREE, $3, 0); }
  1921.     ;
  1922.  
  1923. notype_initdcl0:
  1924.       notype_declarator maybe_raises maybeasm maybe_attribute '='
  1925.         { current_declspecs = $<ttype>0;
  1926.           $<itype>5 = suspend_momentary ();
  1927.           $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
  1928.           cplus_decl_attributes ($<ttype>$, $4); }
  1929.       init
  1930. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1931.         { finish_decl ($<ttype>6, $7, $3, 0);
  1932.           $$ = $<itype>5; }
  1933.     | notype_declarator maybe_raises maybeasm maybe_attribute
  1934.         { tree d;
  1935.           current_declspecs = $<ttype>0;
  1936.           $$ = suspend_momentary ();
  1937.           d = start_decl ($<ttype>1, current_declspecs, 0, $2);
  1938.           cplus_decl_attributes (d, $4);
  1939.           finish_decl (d, NULL_TREE, $3, 0); }
  1940.     ;
  1941.  
  1942. nomods_initdcl0:
  1943.       notype_declarator maybe_raises maybeasm maybe_attribute '='
  1944.         { current_declspecs = NULL_TREE;
  1945.           $<itype>5 = suspend_momentary ();
  1946.           $<ttype>$ = start_decl ($1, current_declspecs, 1, $2);
  1947.           cplus_decl_attributes ($<ttype>$, $4); }
  1948.       init
  1949. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1950.         { finish_decl ($<ttype>6, $7, $3, 0);
  1951.           $$ = $<itype>5; }
  1952.     | notype_declarator maybe_raises maybeasm maybe_attribute
  1953.         { tree d;
  1954.           current_declspecs = NULL_TREE;
  1955.           $$ = suspend_momentary ();
  1956.           d = start_decl ($1, current_declspecs, 0, $2);
  1957.           cplus_decl_attributes (d, $4);
  1958.           finish_decl (d, NULL_TREE, $3, 0); }
  1959.     ;
  1960.  
  1961. /* the * rules are dummies to accept the Apollo extended syntax
  1962.    so that the header files compile. */
  1963. maybe_attribute:
  1964.       /* empty */
  1965.           { $$ = NULL_TREE; }
  1966.     | attributes
  1967.         { $$ = $1; }
  1968.     ;
  1969.  
  1970. attributes:
  1971.       attribute
  1972.         { $$ = $1; }
  1973.     | attributes attribute
  1974.         { $$ = chainon ($1, $2); }
  1975.     ;
  1976.  
  1977. attribute:
  1978.       ATTRIBUTE '(' '(' attribute_list ')' ')'
  1979.         { $$ = $4; }
  1980.     ;
  1981.  
  1982. attribute_list:
  1983.       attrib
  1984.         { $$ = build_tree_list (NULL_TREE, $1); }
  1985.     | attribute_list ',' attrib
  1986.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1987.     ;
  1988.  
  1989. attrib:
  1990.     /* empty */
  1991.         { $$ = NULL_TREE; }
  1992.     | any_word
  1993.         { $$ = $1; }
  1994.     | any_word '(' IDENTIFIER ')'
  1995.         { $$ = tree_cons ($1, NULL_TREE, build_tree_list (NULL_TREE, $3)); }
  1996.     | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  1997.         { $$ = tree_cons ($1, NULL_TREE, tree_cons (NULL_TREE, $3, $5)); }
  1998.     | any_word '(' nonnull_exprlist ')'
  1999.         { $$ = tree_cons ($1, NULL_TREE, $3); }
  2000.     ;
  2001.  
  2002. /* This still leaves out most reserved keywords,
  2003.    shouldn't we include them?  */
  2004.  
  2005. any_word:
  2006.       identifier
  2007.     | SCSPEC
  2008.     | TYPESPEC
  2009.     | TYPE_QUAL
  2010.     ;
  2011.  
  2012. /* A nonempty list of identifiers, including typenames.  */
  2013. identifiers_or_typenames:
  2014.     identifier
  2015.         { $$ = build_tree_list (NULL_TREE, $1); }
  2016.     | identifiers_or_typenames ',' identifier
  2017.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2018.     ;
  2019.  
  2020. init:
  2021.       expr_no_commas %prec '='
  2022.     | '{' '}'
  2023.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
  2024.           TREE_HAS_CONSTRUCTOR ($$) = 1; }
  2025.     | '{' initlist '}'
  2026.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
  2027.           TREE_HAS_CONSTRUCTOR ($$) = 1; }
  2028.     | '{' initlist ',' '}'
  2029.         { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
  2030.           TREE_HAS_CONSTRUCTOR ($$) = 1; }
  2031.     | error
  2032.         { $$ = NULL_TREE; }
  2033.     ;
  2034.  
  2035. /* This chain is built in reverse order,
  2036.    and put in forward order where initlist is used.  */
  2037. initlist:
  2038.       init
  2039.         { $$ = build_tree_list (NULL_TREE, $$); }
  2040.     | initlist ',' init
  2041.         { $$ = tree_cons (NULL_TREE, $3, $$); }
  2042.     /* These are for labeled elements.  */
  2043.     | '[' expr_no_commas ']' init
  2044.         { $$ = build_tree_list ($2, $4); }
  2045.     | initlist ',' CASE expr_no_commas ':' init
  2046.         { $$ = tree_cons ($4, $6, $$); }
  2047.     | identifier ':' init
  2048.         { $$ = build_tree_list ($$, $3); }
  2049.     | initlist ',' identifier ':' init
  2050.         { $$ = tree_cons ($3, $5, $$); }
  2051.     ;
  2052.  
  2053. structsp:
  2054.       ENUM identifier '{'
  2055.         { $<itype>3 = suspend_momentary ();
  2056.           $$ = start_enum ($2); }
  2057.       enumlist maybecomma_warn '}'
  2058.         { $$ = finish_enum ($<ttype>4, $5);
  2059.           resume_momentary ((int) $<itype>3);
  2060.           check_for_missing_semicolon ($<ttype>4); }
  2061.     | ENUM identifier '{' '}'
  2062.         { $$ = finish_enum (start_enum ($2), NULL_TREE);
  2063.           check_for_missing_semicolon ($$); }
  2064.     | ENUM '{'
  2065.         { $<itype>2 = suspend_momentary ();
  2066.           $$ = start_enum (make_anon_name ()); }
  2067.       enumlist maybecomma_warn '}'
  2068.         { $$ = finish_enum ($<ttype>3, $4);
  2069.           resume_momentary ((int) $<itype>1);
  2070.           check_for_missing_semicolon ($<ttype>3); }
  2071.     | ENUM '{' '}'
  2072.         { $$ = finish_enum (start_enum (make_anon_name()), NULL_TREE);
  2073.           check_for_missing_semicolon ($$); }
  2074.     | ENUM identifier
  2075.         { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 0); }
  2076.     | ENUM complex_type_name
  2077.         { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 0); }
  2078.  
  2079.     /* C++ extensions, merged with C to avoid shift/reduce conflicts */
  2080.     | class_head left_curly opt.component_decl_list '}'
  2081.         {
  2082.           int semi;
  2083.           tree id;
  2084.  
  2085. #if 0
  2086.           /* Need to rework class nesting in the
  2087.              presence of nested classes, etc.  */
  2088.           shadow_tag (CLASSTYPE_AS_LIST ($$)); */
  2089. #endif
  2090.           if (yychar == YYEMPTY)
  2091.             yychar = YYLEX;
  2092.           semi = yychar == ';';
  2093.           /* finish_struct nukes this anyway; if
  2094.              finish_exception does too, then it can go. */
  2095.           if (semi)
  2096.             note_got_semicolon ($$);
  2097.  
  2098.           if (TREE_CODE ($$) == ENUMERAL_TYPE)
  2099.             /* $$ = $1 from default rule.  */;
  2100.           else if (CLASSTYPE_DECLARED_EXCEPTION ($$))
  2101.             {
  2102.             }
  2103.           else
  2104.             {
  2105.               $$ = finish_struct ($$, $3, semi);
  2106.               if (semi) note_got_semicolon ($$);
  2107.             }
  2108.  
  2109.           pop_obstacks ();
  2110.  
  2111.           id = TYPE_IDENTIFIER ($$);
  2112.           if (id && IDENTIFIER_TEMPLATE (id))
  2113.             {
  2114.               tree decl;
  2115.  
  2116.               /* I don't know if the copying of this TYPE_DECL is
  2117.                * really needed.  However, it's such a small per-
  2118.                * formance penalty that the extra safety is a bargain.
  2119.                * - niklas@appli.se
  2120.                */
  2121.               push_obstacks (&permanent_obstack, &permanent_obstack);
  2122.               decl = copy_node (lookup_name (id, 0));
  2123.               if (DECL_LANG_SPECIFIC (decl))
  2124.             copy_lang_decl (decl);
  2125.               pop_obstacks ();
  2126.               undo_template_name_overload (id, 0);
  2127.               pushdecl_top_level (decl);
  2128.             }
  2129.           if (! semi)
  2130.             check_for_missing_semicolon ($$); }
  2131.     | class_head  %prec EMPTY
  2132.         {
  2133. #if 0
  2134.   /* It's no longer clear what the following error is supposed to
  2135.      accomplish.  If it turns out to be needed, add a comment why.  */
  2136.           if (TYPE_BINFO_BASETYPES ($$) && !TYPE_SIZE ($$))
  2137.             {
  2138.               error ("incomplete definition of type `%s'",
  2139.                  TYPE_NAME_STRING ($$));
  2140.               $$ = error_mark_node;
  2141.             }
  2142. #endif
  2143.         }
  2144.     ;
  2145.  
  2146. maybecomma:
  2147.       /* empty */
  2148.     | ','
  2149.     ;
  2150.  
  2151. maybecomma_warn:
  2152.       /* empty */
  2153.     | ','
  2154.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  2155.     ;
  2156.  
  2157. aggr:      AGGR
  2158.     | aggr SCSPEC
  2159.         { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
  2160.     | aggr TYPESPEC
  2161.         { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
  2162.     | aggr TYPE_QUAL
  2163.         { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
  2164.     | aggr AGGR
  2165.         { error ("no body nor ';' separates two class, struct or union declarations"); }
  2166.     ;
  2167.  
  2168. specialization:
  2169.       aggr template_type_name ';'
  2170.         { 
  2171.           yyungetc (';', 1); current_aggr = $$; $$ = $2; 
  2172.           if ($<ttype>0 == ridpointers[(int) RID_TEMPLATE])
  2173.             instantiate_class_template ($$, 2);
  2174.         }
  2175.     ;
  2176.  
  2177. named_class_head_sans_basetype:
  2178.       aggr identifier
  2179.         { current_aggr = $$; $$ = $2; }
  2180.     | aggr complex_type_name
  2181.         { current_aggr = $$; $$ = $2; }
  2182.     | aggr template_type %prec EMPTY
  2183.         { current_aggr = $$; $$ = $2; }
  2184.     | aggr template_type_name '{'
  2185.         { yyungetc ('{', 1);
  2186.         aggr2:
  2187.           current_aggr = $$;
  2188.           $$ = $2;
  2189.           overload_template_name ($$, 0); }
  2190.     | aggr template_type_name ':'
  2191.         { yyungetc (':', 1); goto aggr2; }
  2192.     | specialization
  2193.     ;
  2194.  
  2195. named_class_head_sans_basetype_defn:
  2196.       aggr identifier_defn %prec EMPTY
  2197.         { current_aggr = $$; $$ = $2; }
  2198.     ;
  2199.  
  2200. do_xref: /* empty */ %prec EMPTY
  2201.     { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 1); }
  2202.  
  2203. do_xref_defn: /* empty */ %prec EMPTY
  2204.     { $<ttype>$ = xref_defn_tag (current_aggr, $<ttype>0, NULL_TREE); }
  2205.  
  2206. named_class_head:
  2207.       named_class_head_sans_basetype do_xref
  2208.       maybe_base_class_list %prec EMPTY
  2209.         {
  2210.           if ($3)
  2211.             $$ = xref_tag (current_aggr, $1, $3, 1);
  2212.           else
  2213.             $$ = $<ttype>2;
  2214.         }
  2215.     |
  2216.       named_class_head_sans_basetype_defn do_xref_defn
  2217.       maybe_base_class_list %prec EMPTY
  2218.         {
  2219.           if ($3)
  2220.             $$ = xref_defn_tag (current_aggr, $1, $3);
  2221.           else
  2222.             $$ = $<ttype>2;
  2223.         }
  2224.     ;
  2225.  
  2226. unnamed_class_head: aggr '{'
  2227.         { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
  2228.           yyungetc ('{', 1); }
  2229.     ;
  2230.  
  2231. class_head: unnamed_class_head | named_class_head ;
  2232.  
  2233. maybe_base_class_list:
  2234.       %prec EMPTY /* empty */
  2235.         { $$ = NULL_TREE; }
  2236.     | ':'  %prec EMPTY
  2237.         { yyungetc(':', 1); $$ = NULL_TREE; }
  2238.     | ':' base_class_list  %prec EMPTY
  2239.         { $$ = $2; }
  2240.     ;
  2241.  
  2242. base_class_list:
  2243.       base_class
  2244.     | base_class_list ',' base_class
  2245.         { $$ = chainon ($$, $3); }
  2246.     ;
  2247.  
  2248. base_class:
  2249.       base_class.1
  2250.         {
  2251.           tree type;
  2252.          do_base_class1:
  2253.           type = IDENTIFIER_TYPE_VALUE ($$);
  2254.           if (! is_aggr_typedef ($$, 1))
  2255.             $$ = NULL_TREE;
  2256.           else if (current_aggr == signature_type_node
  2257.                && (! type) && (! IS_SIGNATURE (type)))
  2258.             {
  2259.               error ("class name not allowed as base signature");
  2260.               $$ = NULL_TREE;
  2261.             }
  2262.           else if (current_aggr == signature_type_node)
  2263.             {
  2264.               sorry ("signature inheritance, base type `%s' ignored",
  2265.                  IDENTIFIER_POINTER ($$));
  2266.               $$ = build_tree_list ((tree)access_public, $$);
  2267.             }
  2268.           else if (type && IS_SIGNATURE (type))
  2269.             {
  2270.               error ("signature name not allowed as base class");
  2271.               $$ = NULL_TREE;
  2272.             }
  2273.           else
  2274.             $$ = build_tree_list ((tree)access_default, $$);
  2275.         }
  2276.     | base_class_access_list base_class.1
  2277.         {
  2278.           tree type;
  2279.          do_base_class2:
  2280.           type = IDENTIFIER_TYPE_VALUE ($2);
  2281.           if (current_aggr == signature_type_node)
  2282.             error ("access and source specifiers not allowed in signature");
  2283.           if (! is_aggr_typedef ($2, 1))
  2284.             $$ = NULL_TREE;
  2285.           else if (current_aggr == signature_type_node
  2286.                && (! type) && (! IS_SIGNATURE (type)))
  2287.             {
  2288.               error ("class name not allowed as base signature");
  2289.               $$ = NULL_TREE;
  2290.             }
  2291.           else if (current_aggr == signature_type_node)
  2292.             {
  2293.               sorry ("signature inheritance, base type `%s' ignored",
  2294.                  IDENTIFIER_POINTER ($$));
  2295.               $$ = build_tree_list ((tree)access_public, $2);
  2296.             }
  2297.           else if (type && IS_SIGNATURE (type))
  2298.             {
  2299.               error ("signature name not allowed as base class");
  2300.               $$ = NULL_TREE;
  2301.             }
  2302.           else
  2303.             $$ = build_tree_list ((tree) $$, $2);
  2304.         }
  2305.     ;
  2306.  
  2307. base_class.1:
  2308.       complete_type_name
  2309.     | SIGOF '(' expr ')'
  2310.         {
  2311.           if (current_aggr == signature_type_node)
  2312.             {
  2313.               if (IS_AGGR_TYPE (TREE_TYPE ($3)))
  2314.             {
  2315.               sorry ("`sigof' as base signature specifier");
  2316.               /* need to return some dummy signature identifier */
  2317.               $$ = $3;
  2318.             }
  2319.               else
  2320.             {
  2321.               error ("`sigof' applied to non-aggregate expression");
  2322.               $$ = error_mark_node;
  2323.             }
  2324.             }
  2325.           else
  2326.             {
  2327.               error ("`sigof' in struct or class declaration");
  2328.               $$ = error_mark_node;
  2329.             }
  2330.         }
  2331.     | SIGOF '(' type_id ')'
  2332.         {
  2333.           if (current_aggr == signature_type_node)
  2334.             {
  2335.               if (IS_AGGR_TYPE (groktypename ($3)))
  2336.             {
  2337.               sorry ("`sigof' as base signature specifier");
  2338.               /* need to return some dummy signature identifier */
  2339.               $$ = $3;
  2340.             }
  2341.               else
  2342.             {
  2343.               error ("`sigof' applied to non-aggregate expression");
  2344.               $$ = error_mark_node;
  2345.             }
  2346.             }
  2347.           else
  2348.             {
  2349.               error ("`sigof' in struct or class declaration");
  2350.               $$ = error_mark_node;
  2351.             }
  2352.         }
  2353.     ;
  2354.  
  2355. base_class_access_list:
  2356.       VISSPEC
  2357.     | SCSPEC
  2358.         { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
  2359.             sorry ("non-virtual access");
  2360.           $$ = access_default_virtual; }
  2361.     | base_class_access_list VISSPEC
  2362.         { int err = 0;
  2363.           if ($2 == access_protected)
  2364.             {
  2365.               warning ("`protected' access not implemented");
  2366.               $2 = access_public;
  2367.               err++;
  2368.             }
  2369.           else if ($2 == access_public)
  2370.             {
  2371.               if ($1 == access_private)
  2372.             {
  2373.             mixed:
  2374.               error ("base class cannot be public and private");
  2375.             }
  2376.               else if ($1 == access_default_virtual)
  2377.             $$ = access_public_virtual;
  2378.             }
  2379.           else /* $2 == access_private */
  2380.             {
  2381.               if ($1 == access_public)
  2382.             goto mixed;
  2383.               else if ($1 == access_default_virtual)
  2384.             $$ = access_private_virtual;
  2385.             }
  2386.         }
  2387.     | base_class_access_list SCSPEC
  2388.         { if ($2 != ridpointers[(int)RID_VIRTUAL])
  2389.             sorry ("non-virtual access");
  2390.           if ($$ == access_public)
  2391.             $$ = access_public_virtual;
  2392.           else if ($$ == access_private)
  2393.             $$ = access_private_virtual; }
  2394.     ;
  2395.  
  2396. left_curly: '{'
  2397.         { tree t;
  2398.           push_obstacks_nochange ();
  2399.           end_temporary_allocation ();
  2400.  
  2401.           if (! IS_AGGR_TYPE ($<ttype>0))
  2402.             {
  2403.               $<ttype>0 = make_lang_type (RECORD_TYPE);
  2404.               TYPE_NAME ($<ttype>0) = get_identifier ("erroneous type");
  2405.             }
  2406.           if (TYPE_SIZE ($<ttype>0))
  2407.             duplicate_tag_error ($<ttype>0);
  2408.                   if (TYPE_SIZE ($<ttype>0) || TYPE_BEING_DEFINED ($<ttype>0))
  2409.                     {
  2410.                       t = make_lang_type (TREE_CODE ($<ttype>0));
  2411.                       pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
  2412.                       $<ttype>0 = t;
  2413.                     }
  2414.           pushclass ($<ttype>0, 0);
  2415.           TYPE_BEING_DEFINED ($<ttype>0) = 1;
  2416. #if 0
  2417.           t = TYPE_IDENTIFIER ($<ttype>0);
  2418.           if (t && IDENTIFIER_TEMPLATE (t))
  2419.             overload_template_name (t, 1);
  2420. #endif
  2421.         }
  2422.     ;
  2423.  
  2424. opt.component_decl_list:
  2425.     /* empty */
  2426.         { $$ = NULL_TREE; }
  2427.     | component_decl_list
  2428.         {
  2429.           if (current_aggr == signature_type_node)
  2430.             $$ = build_tree_list ((tree) access_public, $$);
  2431.           else
  2432.             $$ = build_tree_list ((tree) access_default, $$);
  2433.         }
  2434.     | opt.component_decl_list VISSPEC ':' component_decl_list
  2435.         {
  2436.           tree visspec = (tree) $2;
  2437.  
  2438.           if (current_aggr == signature_type_node)
  2439.             {
  2440.               error ("access specifier not allowed in signature");
  2441.               visspec = (tree) access_public;
  2442.             }
  2443.           $$ = chainon ($$, build_tree_list (visspec, $4));
  2444.         }
  2445.     | opt.component_decl_list VISSPEC ':'
  2446.         {
  2447.           if (current_aggr == signature_type_node)
  2448.             error ("access specifier not allowed in signature");
  2449.         }
  2450.     ;
  2451.  
  2452. /* Note: we no longer warn about the semicolon after a component_decl_list.
  2453.    ARM $9.2 says that the semicolon is optional, and therefore allowed.  */
  2454. component_decl_list:
  2455.       component_decl
  2456.         { if ($$ == void_type_node) $$ = NULL_TREE; 
  2457.         }
  2458.     | component_decl_list component_decl
  2459.         { /* In pushdecl, we created a reverse list of names
  2460.              in this binding level.  Make sure that the chain
  2461.              of what we're trying to add isn't the item itself
  2462.              (which can happen with what pushdecl's doing).  */
  2463.           if ($2 != NULL_TREE && $2 != void_type_node)
  2464.             {
  2465.               if (TREE_CHAIN ($2) != $$)
  2466.             $$ = chainon ($$, $2);
  2467.               else
  2468.             $$ = $2;
  2469.             }
  2470.         }
  2471.     | component_decl_list ';'
  2472.     ;
  2473.  
  2474. component_decl:
  2475.       component_decl_1 ';'
  2476.     | component_decl_1 '}'
  2477.         { error ("missing ';' before right brace");
  2478.           yyungetc ('}', 0); }
  2479.     /* C++: handle constructors, destructors and inline functions */
  2480.     /* note that INLINE is like a TYPESPEC */
  2481.     | fn.def2 ':' /* base_init compstmt */
  2482.         { $$ = finish_method ($$); }
  2483.     | fn.def2 '{' /* nodecls compstmt */
  2484.         { $$ = finish_method ($$); }
  2485.     ;
  2486.  
  2487. component_decl_1:
  2488.     /* Do not add a "typed_declspecs declarator" rule here for
  2489.        speed; we need to call grok_x_components for enums, so the
  2490.        speedup would be insignificant.  */
  2491.       typed_declspecs components
  2492.         {
  2493.           $$ = grok_x_components ($$, $2);
  2494.         }
  2495.     | declmods notype_components
  2496.         { 
  2497.           $$ = grok_x_components ($$, $2);
  2498.         }
  2499.     | notype_declarator maybe_raises maybeasm maybe_attribute
  2500.         { $$ = grokfield ($$, NULL_TREE, $2, NULL_TREE, $3);
  2501.           cplus_decl_attributes ($$, $4); }
  2502.     | ':' expr_no_commas
  2503.         { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
  2504.     | error
  2505.         { $$ = NULL_TREE; }
  2506.  
  2507.     /* These rules introduce a reduce/reduce conflict; in
  2508.         typedef int foo, bar;
  2509.         class A {
  2510.           foo (bar);
  2511.         };
  2512.        should "A::foo" be declared as a function or "A::bar" as a data
  2513.        member? In other words, is "bar" an after_type_declarator or a
  2514.        parmlist? */
  2515.     | typed_declspecs '(' parmlist ')' type_quals
  2516.         { $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1),
  2517.                      $3, $5);
  2518.           $$ = grokfield ($$, TREE_CHAIN ($1), NULL_TREE, NULL_TREE,
  2519.                   NULL_TREE); }
  2520.     | typed_declspecs LEFT_RIGHT type_quals
  2521.         { $$ = build_parse_node (CALL_EXPR, TREE_VALUE ($1),
  2522.                      empty_parms (), $3);
  2523.           $$ = grokfield ($$, TREE_CHAIN ($1), NULL_TREE, NULL_TREE,
  2524.                   NULL_TREE); }
  2525.     ;
  2526.  
  2527. /* The case of exactly one component is handled directly by component_decl. */
  2528. components:
  2529.       /* empty: possibly anonymous */
  2530.         { $$ = NULL_TREE; }
  2531.     | component_declarator0
  2532.     | components ',' component_declarator
  2533.         {
  2534.           /* In this context, void_type_node encodes
  2535.              friends.  They have been recorded elsewhere.  */
  2536.           if ($$ == void_type_node)
  2537.             $$ = $3;
  2538.           else
  2539.             $$ = chainon ($$, $3);
  2540.         }
  2541.     ;
  2542.  
  2543. notype_components:
  2544.       /* empty: possibly anonymous */
  2545.         { $$ = NULL_TREE; }
  2546.     | notype_component_declarator0
  2547.     | notype_components ',' notype_component_declarator
  2548.         {
  2549.           /* In this context, void_type_node encodes
  2550.              friends.  They have been recorded elsewhere.  */
  2551.           if ($$ == void_type_node)
  2552.             $$ = $3;
  2553.           else
  2554.             $$ = chainon ($$, $3);
  2555.         }
  2556.     ;
  2557.  
  2558. component_declarator0:
  2559.       after_type_component_declarator0
  2560.     | notype_component_declarator0
  2561.     ;
  2562.  
  2563. component_declarator:
  2564.       after_type_component_declarator
  2565.     | notype_component_declarator
  2566.     ;
  2567.  
  2568. after_type_component_declarator0:
  2569.       after_type_declarator maybe_raises maybeasm maybe_attribute
  2570.         { current_declspecs = $<ttype>0;
  2571.           $$ = grokfield ($$, current_declspecs, $2, NULL_TREE, $3);
  2572.           cplus_decl_attributes ($$, $4); }
  2573.     | after_type_declarator maybe_raises maybeasm maybe_attribute '=' init
  2574.         { current_declspecs = $<ttype>0;
  2575.           $$ = grokfield ($$, current_declspecs, $2, $6, $3);
  2576.           cplus_decl_attributes ($$, $4); }
  2577.     | TYPENAME ':' expr_no_commas maybe_attribute
  2578.         { current_declspecs = $<ttype>0;
  2579.           $$ = grokbitfield ($$, current_declspecs, $3);
  2580.           cplus_decl_attributes ($$, $4); }
  2581.     ;
  2582.  
  2583. notype_component_declarator0:
  2584.       notype_declarator maybe_raises maybeasm maybe_attribute
  2585.         { current_declspecs = $<ttype>0;
  2586.           $$ = grokfield ($$, current_declspecs, $2, NULL_TREE, $3);
  2587.           cplus_decl_attributes ($$, $4); }
  2588.     | notype_declarator maybe_raises maybeasm maybe_attribute '=' init
  2589.         { current_declspecs = $<ttype>0;
  2590.           $$ = grokfield ($$, current_declspecs, $2, $6, $3);
  2591.           cplus_decl_attributes ($$, $4); }
  2592.     | IDENTIFIER ':' expr_no_commas maybe_attribute
  2593.         { current_declspecs = $<ttype>0;
  2594.           $$ = grokbitfield ($$, current_declspecs, $3);
  2595.           cplus_decl_attributes ($$, $4); }
  2596.     | ':' expr_no_commas maybe_attribute
  2597.         { current_declspecs = $<ttype>0;
  2598.           $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
  2599.           cplus_decl_attributes ($$, $3); }
  2600.     ;
  2601.  
  2602. after_type_component_declarator:
  2603.       after_type_declarator maybe_raises maybeasm maybe_attribute
  2604.         { $$ = grokfield ($$, current_declspecs, $2, NULL_TREE, $3);
  2605.           cplus_decl_attributes ($$, $4); }
  2606.     | after_type_declarator maybe_raises maybeasm maybe_attribute '=' init
  2607.         { $$ = grokfield ($$, current_declspecs, $2, $6, $3);
  2608.           cplus_decl_attributes ($$, $4); }
  2609.     | TYPENAME ':' expr_no_commas maybe_attribute
  2610.         { $$ = grokbitfield ($$, current_declspecs, $3);
  2611.           cplus_decl_attributes ($$, $4); }
  2612.     ;
  2613.  
  2614. notype_component_declarator:
  2615.       notype_declarator maybe_raises maybeasm maybe_attribute
  2616.         { $$ = grokfield ($$, current_declspecs, $2, NULL_TREE, $3);
  2617.           cplus_decl_attributes ($$, $4); }
  2618.     | notype_declarator maybe_raises maybeasm maybe_attribute '=' init
  2619.         { $$ = grokfield ($$, current_declspecs, $2, $6, $3);
  2620.           cplus_decl_attributes ($$, $4); }
  2621.     | IDENTIFIER ':' expr_no_commas maybe_attribute
  2622.         { $$ = grokbitfield ($$, current_declspecs, $3);
  2623.           cplus_decl_attributes ($$, $4); }
  2624.     | ':' expr_no_commas maybe_attribute
  2625.         { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
  2626.           cplus_decl_attributes ($$, $3); }
  2627.     ;
  2628.  
  2629. /* We chain the enumerators in reverse order.
  2630.    Because of the way enums are built, the order is
  2631.    insignificant.  Take advantage of this fact.  */
  2632.  
  2633. enumlist:
  2634.       enumerator
  2635.     | enumlist ',' enumerator
  2636.         { TREE_CHAIN ($3) = $$; $$ = $3; }
  2637.     ;
  2638.  
  2639. enumerator:
  2640.       identifier
  2641.         { $$ = build_enumerator ($$, NULL_TREE); }
  2642.     | identifier '=' expr_no_commas
  2643.         { $$ = build_enumerator ($$, $3); }
  2644.     ;
  2645.  
  2646. /* ANSI new-type-id (5.3.4) */
  2647. new_type_id:
  2648.       type_specifier_seq new_declarator
  2649.         { $$ = build_decl_list ($$, $2); }
  2650.     | type_specifier_seq %prec EMPTY
  2651.         { $$ = build_decl_list ($$, NULL_TREE); }
  2652.     /* GNU extension to allow arrays of arbitrary types with
  2653.        non-constant dimension.  */
  2654.     | '(' type_id ')' '[' expr ']'
  2655.         {
  2656.           if (flag_ansi)
  2657.             pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
  2658.           $$ = build_parse_node (ARRAY_REF, TREE_VALUE ($2), $5);
  2659.           $$ = build_decl_list (TREE_PURPOSE ($2), $$);
  2660.         }
  2661.     ;
  2662.  
  2663. type_quals:
  2664.       /* empty */ %prec EMPTY
  2665.         { $$ = NULL_TREE; }
  2666.     | type_quals TYPE_QUAL
  2667.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  2668.     ;
  2669.  
  2670. nonempty_type_quals:
  2671.       TYPE_QUAL
  2672.         { $$ = IDENTIFIER_AS_LIST ($$); }
  2673.     | nonempty_type_quals TYPE_QUAL
  2674.         { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
  2675.     ;
  2676.  
  2677. /* These rules must follow the rules for function declarations
  2678.    and component declarations.  That way, longer rules are preferred.  */
  2679.  
  2680. /* An expression which will not live on the momentary obstack.  */
  2681. nonmomentary_expr:
  2682.     { $<itype>$ = suspend_momentary (); } expr
  2683.     { resume_momentary ((int) $<itype>1); $$ = $2; }
  2684.     ;
  2685.  
  2686. /* A declarator that is allowed only after an explicit typespec.  */
  2687. /* may all be followed by prec '.' */
  2688. after_type_declarator:
  2689.       '*' nonempty_type_quals after_type_declarator  %prec UNARY
  2690.         { $$ = make_pointer_declarator ($2, $3); }
  2691.     | '&' nonempty_type_quals after_type_declarator  %prec UNARY
  2692.         { $$ = make_reference_declarator ($2, $3); }
  2693.     | '*' after_type_declarator  %prec UNARY
  2694.         { $$ = make_pointer_declarator (NULL_TREE, $2); }
  2695.     | '&' after_type_declarator  %prec UNARY
  2696.         { $$ = make_reference_declarator (NULL_TREE, $2); }
  2697.     | ptr_to_mem type_quals after_type_declarator
  2698.         { tree arg = make_pointer_declarator ($2, $3);
  2699.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2700.         }
  2701.     | direct_after_type_declarator
  2702.     ;
  2703.  
  2704. qualified_type_name:
  2705.       type_name %prec EMPTY
  2706.         {
  2707.           /* Remember that this name has been used in the class
  2708.              definition, as per [class.scope0] */
  2709.           if (current_class_type
  2710.               && TYPE_BEING_DEFINED (current_class_type)
  2711.               && ! IDENTIFIER_CLASS_VALUE ($$))
  2712.             {
  2713.               tree t = lookup_name ($$, -2);
  2714.               if (t)
  2715.             pushdecl_class_level (t);
  2716.             }
  2717.         }
  2718.     | nested_type
  2719.     ;
  2720.  
  2721. nested_type:
  2722.     nested_name_specifier type_name %prec EMPTY
  2723.         { $$ = $2; }
  2724.     ;
  2725.  
  2726. direct_after_type_declarator:
  2727.       direct_after_type_declarator '(' nonnull_exprlist ')' type_quals %prec '.'
  2728.         { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
  2729.     | direct_after_type_declarator '(' parmlist ')' type_quals %prec '.'
  2730.         { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
  2731.     | direct_after_type_declarator LEFT_RIGHT type_quals %prec '.'
  2732.         { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); }
  2733.     | direct_after_type_declarator '(' error ')' type_quals %prec '.'
  2734.         { $$ = build_parse_node (CALL_EXPR, $$, NULL_TREE, NULL_TREE); }
  2735.     | direct_after_type_declarator '[' nonmomentary_expr ']'
  2736.         { $$ = build_parse_node (ARRAY_REF, $$, $3); }
  2737.     | direct_after_type_declarator '[' ']'
  2738.         { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
  2739.     | '(' after_type_declarator ')'
  2740.         { $$ = $2; }
  2741.     | nested_name_specifier type_name %prec EMPTY
  2742.         { push_nested_class (TREE_TYPE ($$), 3);
  2743.           $$ = build_parse_node (SCOPE_REF, $$, $2);
  2744.           TREE_COMPLEXITY ($$) = current_class_depth; }
  2745.     | type_name %prec EMPTY
  2746.     ;
  2747.  
  2748. /* A declarator allowed whether or not there has been
  2749.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  2750.  
  2751. notype_declarator:
  2752.       '*' nonempty_type_quals notype_declarator  %prec UNARY
  2753.         { $$ = make_pointer_declarator ($2, $3); }
  2754.     | '&' nonempty_type_quals notype_declarator  %prec UNARY
  2755.         { $$ = make_reference_declarator ($2, $3); }
  2756.     | '*' notype_declarator  %prec UNARY
  2757.         { $$ = make_pointer_declarator (NULL_TREE, $2); }
  2758.     | '&' notype_declarator  %prec UNARY
  2759.         { $$ = make_reference_declarator (NULL_TREE, $2); }
  2760.     | ptr_to_mem type_quals notype_declarator
  2761.         { tree arg = make_pointer_declarator ($2, $3);
  2762.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2763.         }
  2764.     | direct_notype_declarator
  2765.     ;
  2766.  
  2767. complex_notype_declarator:
  2768.       '*' nonempty_type_quals notype_declarator  %prec UNARY
  2769.         { $$ = make_pointer_declarator ($2, $3); }
  2770.     | '&' nonempty_type_quals notype_declarator  %prec UNARY
  2771.         { $$ = make_reference_declarator ($2, $3); }
  2772.     | '*' complex_notype_declarator  %prec UNARY
  2773.         { $$ = make_pointer_declarator (NULL_TREE, $2); }
  2774.     | '&' complex_notype_declarator  %prec UNARY
  2775.         { $$ = make_reference_declarator (NULL_TREE, $2); }
  2776.     | ptr_to_mem type_quals notype_declarator
  2777.         { tree arg = make_pointer_declarator ($2, $3);
  2778.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2779.         }
  2780.     | complex_direct_notype_declarator
  2781.     ;
  2782.  
  2783. complex_direct_notype_declarator:
  2784.       direct_notype_declarator '(' nonnull_exprlist ')' type_quals  %prec '.'
  2785.         { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
  2786.     | direct_notype_declarator '(' parmlist ')' type_quals  %prec '.'
  2787.         { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
  2788.     | direct_notype_declarator LEFT_RIGHT type_quals  %prec '.'
  2789.         { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); }
  2790.     | direct_notype_declarator '(' error ')' type_quals  %prec '.'
  2791.         { $$ = build_parse_node (CALL_EXPR, $$, NULL_TREE, NULL_TREE); }
  2792.     | '(' expr_or_declarator ')'
  2793.         { $$ = finish_decl_parsing ($2); }
  2794.     | '(' complex_notype_declarator ')'
  2795.         { $$ = $2; }
  2796.     | direct_notype_declarator '[' nonmomentary_expr ']'
  2797.         { $$ = build_parse_node (ARRAY_REF, $$, $3); }
  2798.     | direct_notype_declarator '[' ']'
  2799.         { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
  2800.     ;
  2801.  
  2802. qualified_id:
  2803.     nested_name_specifier unqualified_id
  2804.         { got_scope = NULL_TREE;
  2805.           $$ = build_parse_node (SCOPE_REF, $$, $2); }
  2806.     ;
  2807.  
  2808. notype_qualified_id:
  2809.     nested_name_specifier notype_unqualified_id
  2810.         { got_scope = NULL_TREE;
  2811.           $$ = build_parse_node (SCOPE_REF, $$, $2); }
  2812.     ;
  2813.  
  2814. overqualified_id:
  2815.       notype_qualified_id
  2816.     | global_scope notype_qualified_id
  2817.         { $$ = $2; }
  2818.     ;
  2819.  
  2820. functional_cast:
  2821.       typespec '(' nonnull_exprlist ')'
  2822.         { $$ = build_functional_cast ($$, $3); }
  2823.     | typespec '(' expr_or_declarator ')'
  2824.         { $$ = reparse_decl_as_expr ($$, $3); }
  2825.     | typespec fcast_or_absdcl %prec EMPTY
  2826.         { $$ = reparse_absdcl_as_expr ($$, $2); }
  2827.     ;
  2828.  
  2829. type_name:
  2830.       TYPENAME
  2831.     | template_type %prec EMPTY
  2832.     ;
  2833.  
  2834. nested_name_specifier:
  2835.       nested_name_specifier_1
  2836.     | nested_name_specifier nested_name_specifier_1
  2837.         { $$ = $2; }
  2838.     ;
  2839.  
  2840. /* Why the @#$%^& do type_name and notype_identifier need to be expanded
  2841.    inline here?!?  (jason) */
  2842. nested_name_specifier_1:
  2843.       TYPENAME SCOPE
  2844.         { got_scope = TREE_TYPE ($$); }
  2845.     | template_type SCOPE
  2846.         { got_scope = TREE_TYPE ($$); }
  2847. /*     These break 'const i;'
  2848.     | IDENTIFIER SCOPE
  2849.         {
  2850.          failed_scope:
  2851.           cp_error ("`%D' is not an aggregate typedef", 
  2852.                 lastiddecl ? lastiddecl : $$);
  2853.           $$ = error_mark_node;
  2854.         }
  2855.     | PTYPENAME SCOPE
  2856.         { goto failed_scope; } */
  2857.     ;
  2858.  
  2859. complete_type_name:
  2860.       qualified_type_name
  2861.     | global_scope qualified_type_name
  2862.         { $$ = $2; }
  2863.     ;
  2864.  
  2865. complex_type_name:
  2866.       nested_type
  2867.     | global_scope qualified_type_name
  2868.         { $$ = $2; }
  2869.     ;
  2870.  
  2871. ptr_to_mem:
  2872.       nested_name_specifier '*'
  2873.         { got_scope = NULL_TREE; }
  2874.     | global_scope nested_name_specifier '*'
  2875.         { $$ = $2; got_scope = NULL_TREE; }
  2876.     ;
  2877.  
  2878. /* All uses of explicit global scope must go through this nonterminal so
  2879.    that got_scope will be set before yylex is called to get the next token. */
  2880. global_scope:
  2881.       SCOPE
  2882.         { got_scope = void_type_node; }
  2883.     ;
  2884.  
  2885. /* ANSI new-declarator (5.3.4) */
  2886. new_declarator:
  2887.       '*' type_quals new_declarator
  2888.         { $$ = make_pointer_declarator ($2, $3); }
  2889.     | '*' type_quals  %prec EMPTY
  2890.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  2891.     | '&' type_quals new_declarator %prec EMPTY
  2892.         { $$ = make_reference_declarator ($2, $3); }
  2893.     | '&' type_quals %prec EMPTY
  2894.         { $$ = make_reference_declarator ($2, NULL_TREE); }
  2895.     | ptr_to_mem type_quals %prec EMPTY
  2896.         { tree arg = make_pointer_declarator ($2, NULL_TREE);
  2897.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2898.         }
  2899.     | ptr_to_mem type_quals new_declarator
  2900.         { tree arg = make_pointer_declarator ($2, $3);
  2901.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2902.         }
  2903.     | direct_new_declarator %prec EMPTY
  2904.     ;
  2905.  
  2906. /* ANSI direct-new-declarator (5.3.4) */
  2907. direct_new_declarator:
  2908.       '[' expr ']'
  2909.         { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
  2910.     | direct_new_declarator '[' nonmomentary_expr ']'
  2911.         { $$ = build_parse_node (ARRAY_REF, $$, $3); }
  2912.     ;
  2913.  
  2914. /* ANSI abstract-declarator (8.1) */
  2915. absdcl:
  2916.       '*' nonempty_type_quals absdcl
  2917.         { $$ = make_pointer_declarator ($2, $3); }
  2918.     | '*' absdcl
  2919.         { $$ = make_pointer_declarator (NULL_TREE, $2); }
  2920.     | '*' nonempty_type_quals  %prec EMPTY
  2921.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  2922.     | '*' %prec EMPTY
  2923.         { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
  2924.     | '&' nonempty_type_quals absdcl
  2925.         { $$ = make_reference_declarator ($2, $3); }
  2926.     | '&' absdcl
  2927.         { $$ = make_reference_declarator (NULL_TREE, $2); }
  2928.     | '&' nonempty_type_quals %prec EMPTY
  2929.         { $$ = make_reference_declarator ($2, NULL_TREE); }
  2930.     | '&' %prec EMPTY
  2931.         { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
  2932.     | ptr_to_mem type_quals %prec EMPTY
  2933.         { tree arg = make_pointer_declarator ($2, NULL_TREE);
  2934.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2935.         }
  2936.     | ptr_to_mem type_quals absdcl
  2937.         { tree arg = make_pointer_declarator ($2, $3);
  2938.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  2939.         }
  2940.     | direct_abstract_declarator %prec EMPTY
  2941.     ;
  2942.  
  2943. /* ANSI direct-abstract-declarator (8.1) */
  2944. direct_abstract_declarator:
  2945.       '(' absdcl ')'
  2946.         { $$ = $2; }
  2947.       /* `(typedef)1' is `int'.  */
  2948.     | PAREN_STAR_PAREN
  2949.     | direct_abstract_declarator '(' parmlist ')' type_quals  %prec '.'
  2950.         { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
  2951.     | direct_abstract_declarator LEFT_RIGHT type_quals  %prec '.'
  2952.         { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); }
  2953.     | direct_abstract_declarator '[' nonmomentary_expr ']'  %prec '.'
  2954.         { $$ = build_parse_node (ARRAY_REF, $$, $3); }
  2955.     | direct_abstract_declarator '[' ']'  %prec '.'
  2956.         { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
  2957.     | '(' complex_parmlist ')' type_quals  %prec '.'
  2958.         { $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); }
  2959.     | regcast_or_absdcl type_quals %prec '.'
  2960.         { TREE_OPERAND ($$, 2) = $2; }
  2961.     | fcast_or_absdcl type_quals %prec '.'
  2962.         { TREE_OPERAND ($$, 2) = $2; }
  2963.     | '[' nonmomentary_expr ']'  %prec '.'
  2964.         { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
  2965.     | '[' ']'  %prec '.'
  2966.         { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
  2967.     ;
  2968.  
  2969. /* For C++, decls and stmts can be intermixed, so we don't need to
  2970.    have a special rule that won't start parsing the stmt section
  2971.    until we have a stmt that parses without errors.  */
  2972.  
  2973. stmts:
  2974.       stmt
  2975.     | errstmt
  2976.     | stmts stmt
  2977.     | stmts errstmt
  2978.     ;
  2979.  
  2980. errstmt:  error ';'
  2981.     ;
  2982.  
  2983. /* build the LET_STMT node before parsing its contents,
  2984.   so that any LET_STMTs within the context can have their display pointers
  2985.   set up to point at this one.  */
  2986.  
  2987. .pushlevel:  /* empty */
  2988.         { emit_line_note (input_filename, lineno);
  2989.           pushlevel (0);
  2990.           clear_last_expr ();
  2991.           push_momentary ();
  2992.           expand_start_bindings (0); }
  2993.     ;
  2994.  
  2995. /* Read zero or more forward-declarations for labels
  2996.    that nested functions can jump to.  */
  2997. maybe_label_decls:
  2998.       /* empty */
  2999.     | label_decls
  3000.         { if (flag_ansi)
  3001.             pedwarn ("ANSI C++ forbids label declarations"); }
  3002.     ;
  3003.  
  3004. label_decls:
  3005.       label_decl
  3006.     | label_decls label_decl
  3007.     ;
  3008.  
  3009. label_decl:
  3010.       LABEL identifiers_or_typenames ';'
  3011.         { tree link;
  3012.           for (link = $2; link; link = TREE_CHAIN (link))
  3013.             {
  3014.               tree label = shadow_label (TREE_VALUE (link));
  3015.               C_DECLARED_LABEL_FLAG (label) = 1;
  3016.               declare_nonlocal_label (label);
  3017.             }
  3018.         }
  3019.     ;
  3020.  
  3021. /* This is the body of a function definition.
  3022.    It causes syntax errors to ignore to the next openbrace.  */
  3023. compstmt_or_error:
  3024.       compstmt
  3025.         {}
  3026.     | error compstmt
  3027.     ;
  3028.  
  3029. compstmt: '{' .pushlevel '}'
  3030.         { expand_end_bindings (getdecls (), kept_level_p(), 1);
  3031.           $$ = poplevel (kept_level_p (), 1, 0);
  3032.           pop_momentary (); }
  3033.     | '{' .pushlevel maybe_label_decls stmts '}'
  3034.         { expand_end_bindings (getdecls (), kept_level_p(), 1);
  3035.           $$ = poplevel (kept_level_p (), 1, 0);
  3036.           pop_momentary (); }
  3037.     | '{' .pushlevel maybe_label_decls stmts error '}'
  3038.         { expand_end_bindings (getdecls (), kept_level_p(), 1);
  3039.           $$ = poplevel (kept_level_p (), 0, 0);
  3040.           pop_momentary (); }
  3041.     | '{' .pushlevel maybe_label_decls error '}'
  3042.         { expand_end_bindings (getdecls (), kept_level_p(), 1);
  3043.           $$ = poplevel (kept_level_p (), 0, 0);
  3044.           pop_momentary (); }
  3045.     ;
  3046.  
  3047. simple_if:
  3048.       IF
  3049.         { cond_stmt_keyword = "if"; }
  3050.       .pushlevel paren_cond_or_null
  3051.         { emit_line_note (input_filename, lineno);
  3052.           expand_start_cond (bool_truthvalue_conversion ($4), 0); }
  3053.       implicitly_scoped_stmt
  3054.     ;
  3055.  
  3056. implicitly_scoped_stmt:
  3057.       compstmt
  3058.         { finish_stmt (); }
  3059.     | .pushlevel simple_stmt
  3060.         { expand_end_bindings (getdecls (), kept_level_p (), 1);
  3061.           $$ = poplevel (kept_level_p (), 1, 0);
  3062.           pop_momentary (); }
  3063.     ;
  3064.  
  3065. stmt:
  3066.       compstmt
  3067.         { finish_stmt (); }
  3068.     | simple_stmt
  3069.     ;
  3070.  
  3071. simple_stmt:
  3072.       decl
  3073.         { finish_stmt (); }
  3074.     | expr ';'
  3075.         {
  3076.           tree expr = $1;
  3077.           emit_line_note (input_filename, lineno);
  3078.           /* Do default conversion if safe and possibly important,
  3079.              in case within ({...}).  */
  3080.           if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
  3081.                && lvalue_p (expr))
  3082.               || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
  3083.             expr = default_conversion (expr);
  3084.           cplus_expand_expr_stmt (expr);
  3085.           clear_momentary ();
  3086.           finish_stmt (); }
  3087.     | simple_if ELSE
  3088.         { expand_start_else (); }
  3089.       implicitly_scoped_stmt
  3090.         { expand_end_cond ();
  3091.           expand_end_bindings (getdecls (), kept_level_p (), 1);
  3092.           poplevel (kept_level_p (), 1, 0);
  3093.           pop_momentary ();
  3094.           finish_stmt (); }
  3095.     | simple_if %prec IF
  3096.         { expand_end_cond ();
  3097.           expand_end_bindings (getdecls (), kept_level_p (), 1);
  3098.           poplevel (kept_level_p (), 1, 0);
  3099.           pop_momentary ();
  3100.           finish_stmt (); }
  3101.     | WHILE
  3102.         { emit_nop ();
  3103.           emit_line_note (input_filename, lineno);
  3104.           expand_start_loop (1);
  3105.           cond_stmt_keyword = "while"; }
  3106.       .pushlevel paren_cond_or_null
  3107.         { expand_exit_loop_if_false (0, bool_truthvalue_conversion ($4)); }
  3108.       already_scoped_stmt
  3109.         { expand_end_bindings (getdecls (), kept_level_p (), 1);
  3110.           poplevel (kept_level_p (), 1, 0);
  3111.           pop_momentary ();
  3112.           expand_end_loop ();
  3113.           finish_stmt (); }
  3114.     | DO
  3115.         { emit_nop ();
  3116.           emit_line_note (input_filename, lineno);
  3117.           expand_start_loop_continue_elsewhere (1); }
  3118.       implicitly_scoped_stmt WHILE
  3119.         { expand_loop_continue_here ();
  3120.           cond_stmt_keyword = "do"; }
  3121.       paren_expr_or_null ';'
  3122.         { emit_line_note (input_filename, lineno);
  3123.           expand_exit_loop_if_false (0, bool_truthvalue_conversion ($6));
  3124.           expand_end_loop ();
  3125.           clear_momentary ();
  3126.           finish_stmt (); }
  3127.     | forhead.1
  3128.         { emit_nop ();
  3129.           emit_line_note (input_filename, lineno);
  3130.           if ($1) cplus_expand_expr_stmt ($1);
  3131.           expand_start_loop_continue_elsewhere (1); }
  3132.       .pushlevel xcond ';'
  3133.         { emit_line_note (input_filename, lineno);
  3134.           if ($4) expand_exit_loop_if_false (0, bool_truthvalue_conversion ($4)); }
  3135.       xexpr ')'
  3136.         /* Don't let the tree nodes for $7 be discarded
  3137.            by clear_momentary during the parsing of the next stmt.  */
  3138.         { push_momentary (); }
  3139.       already_scoped_stmt
  3140.         { emit_line_note (input_filename, lineno);
  3141.           expand_end_bindings (getdecls (), kept_level_p (), 1);
  3142.           poplevel (kept_level_p (), 1, 0);
  3143.           pop_momentary ();
  3144.           expand_loop_continue_here ();
  3145.           if ($7) cplus_expand_expr_stmt ($7);
  3146.           pop_momentary ();
  3147.           expand_end_loop ();
  3148.           finish_stmt (); }
  3149.     | forhead.2
  3150.         { emit_nop ();
  3151.           emit_line_note (input_filename, lineno);
  3152.           expand_start_loop_continue_elsewhere (1); }
  3153.       .pushlevel xcond ';'
  3154.         { emit_line_note (input_filename, lineno);
  3155.           if ($4) expand_exit_loop_if_false (0, bool_truthvalue_conversion ($4)); }
  3156.       xexpr ')'
  3157.         /* Don't let the tree nodes for $7 be discarded
  3158.            by clear_momentary during the parsing of the next stmt.  */
  3159.         { push_momentary ();
  3160.           $<itype>8 = lineno; }
  3161.       already_scoped_stmt
  3162.         { emit_line_note (input_filename, (int) $<itype>8);
  3163.           expand_end_bindings (getdecls (), kept_level_p (), 1);
  3164.           poplevel (kept_level_p (), 1, 0);
  3165.           pop_momentary ();
  3166.           expand_loop_continue_here ();
  3167.           if ($7) cplus_expand_expr_stmt ($7);
  3168.           pop_momentary ();
  3169.           expand_end_loop ();
  3170.           finish_stmt ();
  3171.         }
  3172.     | SWITCH .pushlevel '(' condition ')'
  3173.         { emit_line_note (input_filename, lineno);
  3174.           c_expand_start_case ($4); 
  3175.           /* Don't let the tree nodes for $4 be discarded by
  3176.              clear_momentary during the parsing of the next stmt.  */
  3177.           push_momentary (); }
  3178.       implicitly_scoped_stmt
  3179.         { expand_end_case ($4);
  3180.           pop_momentary ();
  3181.           expand_end_bindings (getdecls (), kept_level_p (), 1);
  3182.           poplevel (kept_level_p (), 1, 0);
  3183.           pop_momentary ();
  3184.           finish_stmt (); }
  3185.     | CASE expr_no_commas ':'
  3186.         { register tree value = check_cp_case_value ($2);
  3187.           register tree label
  3188.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  3189.  
  3190.           if (value != error_mark_node)
  3191.             {
  3192.               tree duplicate;
  3193.               int success = pushcase (value, convert_and_check,
  3194.                           label, &duplicate);
  3195.               if (success == 1)
  3196.             cp_error ("case label `%E' not within a switch statement", $2);
  3197.               else if (success == 2)
  3198.             {
  3199.               cp_error ("duplicate case value `%E'", $2);
  3200.               cp_error_at ("`%E' previously used here", duplicate);
  3201.             }
  3202.               else if (success == 3)
  3203.             warning ("case value out of range");
  3204.               else if (success == 5)
  3205.             cp_error ("case label `%E' within scope of cleanup or variable array", $2);
  3206.             }
  3207.           define_case_label (label);
  3208.         }
  3209.       stmt
  3210.     | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  3211.         { register tree value1 = check_cp_case_value ($2);
  3212.           register tree value2 = check_cp_case_value ($4);
  3213.           register tree label
  3214.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  3215.  
  3216.           if (flag_ansi)
  3217.             pedwarn ("ANSI C++ forbids range expressions in switch statement");
  3218.           if (value1 != error_mark_node
  3219.               && value2 != error_mark_node)
  3220.             {
  3221.               tree duplicate;
  3222.               int success = pushcase_range (value1, value2,
  3223.                             convert_and_check, label,
  3224.                             &duplicate);
  3225.               if (success == 1)
  3226.             error ("case label not within a switch statement");
  3227.               else if (success == 2)
  3228.             {
  3229.               error ("duplicate (or overlapping) case value");
  3230.               error_with_decl (duplicate, "this is the first entry overlapping that value");
  3231.             }
  3232.               else if (success == 3)
  3233.             warning ("case value out of range");
  3234.               else if (success == 4)
  3235.             warning ("empty range specified");
  3236.               else if (success == 5)
  3237.             error ("case label within scope of cleanup or variable array");
  3238.             }
  3239.           define_case_label (label);
  3240.         }
  3241.       stmt
  3242.     | DEFAULT ':'
  3243.         {
  3244.           tree duplicate;
  3245.           register tree label
  3246.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  3247.           int success = pushcase (NULL_TREE, 0, label, &duplicate);
  3248.           if (success == 1)
  3249.             error ("default label not within a switch statement");
  3250.           else if (success == 2)
  3251.             {
  3252.               error ("multiple default labels in one switch");
  3253.               error_with_decl (duplicate, "this is the first default label");
  3254.             }
  3255.           define_case_label (NULL_TREE);
  3256.         }
  3257.       stmt
  3258.     | BREAK ';'
  3259.         { emit_line_note (input_filename, lineno);
  3260.           if ( ! expand_exit_something ())
  3261.             error ("break statement not within loop or switch"); }
  3262.     | CONTINUE ';'
  3263.         { emit_line_note (input_filename, lineno);
  3264.           if (! expand_continue_loop (0))
  3265.             error ("continue statement not within a loop"); }
  3266.     | RETURN ';'
  3267.         { emit_line_note (input_filename, lineno);
  3268.           c_expand_return (NULL_TREE); }
  3269.     | RETURN expr ';'
  3270.         { emit_line_note (input_filename, lineno);
  3271.           c_expand_return ($2);
  3272.           finish_stmt ();
  3273.         }
  3274.     | asm_keyword maybe_type_qual '(' string ')' ';'
  3275.         { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
  3276.           emit_line_note (input_filename, lineno);
  3277.           expand_asm ($4);
  3278.           finish_stmt ();
  3279.         }
  3280.     /* This is the case with just output operands.  */
  3281.     | asm_keyword maybe_type_qual '(' string ':' asm_operands ')' ';'
  3282.         { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
  3283.           emit_line_note (input_filename, lineno);
  3284.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  3285.                      $2 == ridpointers[(int)RID_VOLATILE],
  3286.                      input_filename, lineno);
  3287.           finish_stmt ();
  3288.         }
  3289.     /* This is the case with input operands as well.  */
  3290.     | asm_keyword maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';'
  3291.         { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
  3292.           emit_line_note (input_filename, lineno);
  3293.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  3294.                      $2 == ridpointers[(int)RID_VOLATILE],
  3295.                      input_filename, lineno);
  3296.           finish_stmt ();
  3297.         }
  3298.     /* This is the case with clobbered registers as well.  */
  3299.     | asm_keyword maybe_type_qual '(' string ':' asm_operands ':'
  3300.       asm_operands ':' asm_clobbers ')' ';'
  3301.         { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
  3302.           emit_line_note (input_filename, lineno);
  3303.           c_expand_asm_operands ($4, $6, $8, $10,
  3304.                      $2 == ridpointers[(int)RID_VOLATILE],
  3305.                      input_filename, lineno);
  3306.           finish_stmt ();
  3307.         }
  3308.     | GOTO '*' expr ';'
  3309.         { emit_line_note (input_filename, lineno);
  3310.           expand_computed_goto ($3); }
  3311.     | GOTO identifier ';'
  3312.         { tree decl;
  3313.           emit_line_note (input_filename, lineno);
  3314.           decl = lookup_label ($2);
  3315.           TREE_USED (decl) = 1;
  3316.           expand_goto (decl); }
  3317.     | label_colon stmt
  3318.         { finish_stmt (); }
  3319.     | label_colon '}'
  3320.         { error ("label must be followed by statement");
  3321.           yyungetc ('}', 0);
  3322.           finish_stmt (); }
  3323.     | ';'
  3324.         { finish_stmt (); }
  3325.     | try_block
  3326.     ;
  3327.  
  3328. try_block:
  3329.       TRY '{' .pushlevel
  3330.         { expand_start_try_stmts (); }
  3331.       ansi_try_stmts
  3332.         { expand_end_try_stmts ();
  3333.           expand_start_all_catch (); }
  3334.       handler_seq
  3335.         { expand_end_all_catch (); }
  3336.     ;
  3337.  
  3338. ansi_try_stmts:
  3339.       '}'
  3340.         /* An empty try block is degenerate, but it's better to
  3341.            do extra work here than to do all the special-case work
  3342.            everywhere else.  */
  3343.         { expand_end_bindings (0,1,1);
  3344.           poplevel (2,0,0);
  3345.         }
  3346.     | stmts '}'
  3347.         { expand_end_bindings (0,1,1);
  3348.           poplevel (2,0,0);
  3349.         }
  3350.     | error '}'
  3351.         { expand_end_bindings (0,1,1);
  3352.           poplevel (2,0,0);
  3353.         }
  3354.     ;
  3355.  
  3356. handler_seq:
  3357.       /* empty */
  3358.     | handler_seq CATCH
  3359.         { emit_line_note (input_filename, lineno); }
  3360.       handler_args compstmt
  3361.         { expand_end_catch_block (); }
  3362.     ;
  3363.  
  3364. type_specifier_seq:
  3365.       typed_typespecs %prec EMPTY
  3366.     | nonempty_type_quals %prec EMPTY
  3367.     ;
  3368.  
  3369. handler_args:
  3370.       '(' ELLIPSIS ')'
  3371.         { expand_start_catch_block (NULL_TREE, NULL_TREE); }
  3372.     /* This doesn't allow reference parameters, the below does.
  3373.     | '(' type_specifier_seq absdcl ')'
  3374.         { expand_start_catch_block ($2, $3); }
  3375.     | '(' type_specifier_seq ')'
  3376.         { expand_start_catch_block ($2, NULL_TREE); }
  3377.     | '(' type_specifier_seq notype_declarator ')'
  3378.         { expand_start_catch_block ($2, $3); }
  3379.     | '(' typed_typespecs after_type_declarator ')'
  3380.         { expand_start_catch_block ($2, $3); }
  3381.     */
  3382.     | '(' parm ')'
  3383.         { expand_start_catch_block (TREE_PURPOSE ($2),
  3384.                         TREE_VALUE ($2)); }
  3385.     ;
  3386.  
  3387. label_colon:
  3388.       IDENTIFIER ':'
  3389.         { tree label;
  3390.         do_label:
  3391.           label = define_label (input_filename, lineno, $1);
  3392.           if (label)
  3393.             expand_label (label);
  3394.         }
  3395.     | PTYPENAME ':'
  3396.         { goto do_label; }
  3397.     ;
  3398.  
  3399. forhead.1:
  3400.       FOR '(' ';'
  3401.         { $$ = NULL_TREE; }
  3402.     | FOR '(' expr ';'
  3403.         { $$ = $3; }
  3404.     | FOR '(' '{' '}'
  3405.         { $$ = NULL_TREE; }
  3406.     ;
  3407.  
  3408. forhead.2:
  3409.       FOR '(' decl
  3410.         { $$ = 0; }
  3411.     | FOR '(' error ';'
  3412.         { $$ = 0; }
  3413.     | FOR '(' '{' .pushlevel stmts '}'
  3414.         { $$ = 1; }
  3415.     | FOR '(' '{' .pushlevel error '}'
  3416.         { $$ = -1; }
  3417.     ;
  3418.  
  3419. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  3420.  
  3421. maybe_type_qual:
  3422.     /* empty */
  3423.         { emit_line_note (input_filename, lineno);
  3424.           $$ = NULL_TREE; }
  3425.     | TYPE_QUAL
  3426.         { emit_line_note (input_filename, lineno); }
  3427.     ;
  3428.  
  3429. xexpr:
  3430.     /* empty */
  3431.         { $$ = NULL_TREE; }
  3432.     | expr
  3433.     | error
  3434.         { $$ = NULL_TREE; }
  3435.     ;
  3436.  
  3437. /* These are the operands other than the first string and colon
  3438.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  3439. asm_operands: /* empty */
  3440.         { $$ = NULL_TREE; }
  3441.     | nonnull_asm_operands
  3442.     ;
  3443.  
  3444. nonnull_asm_operands:
  3445.       asm_operand
  3446.     | nonnull_asm_operands ',' asm_operand
  3447.         { $$ = chainon ($$, $3); }
  3448.     ;
  3449.  
  3450. asm_operand:
  3451.       STRING '(' expr ')'
  3452.         { $$ = build_tree_list ($$, $3); }
  3453.     ;
  3454.  
  3455. asm_clobbers:
  3456.       STRING
  3457.         { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
  3458.     | asm_clobbers ',' STRING
  3459.         { $$ = tree_cons (NULL_TREE, $3, $$); }
  3460.     ;
  3461.  
  3462. /* This is what appears inside the parens in a function declarator.
  3463.    Its value is represented in the format that grokdeclarator expects.
  3464.  
  3465.    In C++, declaring a function with no parameters
  3466.    means that that function takes *no* parameters.  */
  3467.  
  3468. parmlist:  /* empty */
  3469.         {
  3470.           if (strict_prototype)
  3471.             $$ = void_list_node;
  3472.           else
  3473.             $$ = NULL_TREE;
  3474.         }
  3475.     | complex_parmlist
  3476.     | type_id
  3477.         { $$ = tree_cons (NULL_TREE, $$, void_list_node);
  3478.           TREE_PARMLIST ($$) = 1; }
  3479.     ;
  3480.  
  3481. /* This nonterminal does not include the common sequence '(' type_id ')',
  3482.    as it is ambiguous and must be disambiguated elsewhere.  */
  3483. complex_parmlist:
  3484.       parms
  3485.         {
  3486.           $$ = chainon ($$, void_list_node);
  3487.           TREE_PARMLIST ($$) = 1;
  3488.         }
  3489.     | parms_comma ELLIPSIS
  3490.         {
  3491.           TREE_PARMLIST ($$) = 1;
  3492.         }
  3493.     /* C++ allows an ellipsis without a separating ',' */
  3494.     | parms ELLIPSIS
  3495.         {
  3496.           TREE_PARMLIST ($$) = 1;
  3497.         }
  3498.     | type_id ELLIPSIS
  3499.         {
  3500.           $$ = build_tree_list (NULL_TREE, $$); 
  3501.           TREE_PARMLIST ($$) = 1;
  3502.         }
  3503.     | ELLIPSIS
  3504.         {
  3505.           /* ARM $8.2.5 has this as a boxed-off comment.  */
  3506.           if (pedantic)
  3507.             warning ("use of `...' without a first argument is non-portable");
  3508.           $$ = NULL_TREE;
  3509.         }
  3510.     | TYPENAME_ELLIPSIS
  3511.         {
  3512.           TREE_PARMLIST ($$) = 1;
  3513.         }
  3514.     | parms TYPENAME_ELLIPSIS
  3515.         {
  3516.           TREE_PARMLIST ($$) = 1;
  3517.         }
  3518.     | type_id TYPENAME_ELLIPSIS
  3519.         {
  3520.           $$ = build_tree_list (NULL_TREE, $$);
  3521.           TREE_PARMLIST ($$) = 1;
  3522.         }
  3523.     | parms ':'
  3524.         {
  3525.           /* This helps us recover from really nasty
  3526.              parse errors, for example, a missing right
  3527.              parenthesis.  */
  3528.           yyerror ("possibly missing ')'");
  3529.           $$ = chainon ($$, void_list_node);
  3530.           TREE_PARMLIST ($$) = 1;
  3531.           yyungetc (':', 0);
  3532.           yychar = ')';
  3533.         }
  3534.     | type_id ':'
  3535.         {
  3536.           /* This helps us recover from really nasty
  3537.              parse errors, for example, a missing right
  3538.              parenthesis.  */
  3539.           yyerror ("possibly missing ')'");
  3540.           $$ = tree_cons (NULL_TREE, $$, void_list_node);
  3541.           TREE_PARMLIST ($$) = 1;
  3542.           yyungetc (':', 0);
  3543.           yychar = ')';
  3544.         }
  3545.     ;
  3546.  
  3547. /* A nonempty list of parameter declarations or type names.  */
  3548. parms:
  3549.       named_parm
  3550.         { $$ = build_tree_list (NULL_TREE, $$); }
  3551.     | parm '=' init
  3552.         { $$ = build_tree_list ($3, $$); }
  3553.     | parms_comma parm
  3554.         { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
  3555.     | parms_comma parm '=' init
  3556.         { $$ = chainon ($$, build_tree_list ($4, $2)); }
  3557.     | parms_comma bad_parm
  3558.         { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
  3559.     | parms_comma bad_parm '=' init
  3560.         { $$ = chainon ($$, build_tree_list ($4, $2)); }
  3561.     ;
  3562.  
  3563. parms_comma:
  3564.       parms ','
  3565.     | type_id ','
  3566.         { $$ = build_tree_list (NULL_TREE, $$); }
  3567.     ;
  3568.  
  3569. /* A single parameter declaration or parameter type name,
  3570.    as found in a parmlist.  The first four cases make up for 10%
  3571.    of the time spent parsing C++.  We cannot use them because
  3572.    of `int id[]' which won't get parsed properly.  */
  3573. named_parm:
  3574. /*
  3575.       typed_declspecs dont_see_typename '*' IDENTIFIER
  3576.         { $$ = build_tree_list ($$, build_parse_node (INDIRECT_REF, $4));
  3577.           see_typename (); }
  3578.     | typed_declspecs dont_see_typename '&' IDENTIFIER
  3579.         { $$ = build_tree_list ($$, build_parse_node (ADDR_EXPR, $4));
  3580.           see_typename (); }
  3581.     | TYPENAME IDENTIFIER
  3582.         { $$ = build_tree_list (get_decl_list ($$), $2);  }
  3583.     | TYPESPEC IDENTIFIER
  3584.         { $$ = build_tree_list (get_decl_list ($$), $2); }
  3585.     | */
  3586.     /* Here we expand typed_declspecs inline to avoid mis-parsing of
  3587.        TYPESPEC IDENTIFIER.  */
  3588.       typed_declspecs1 declarator
  3589.         { $$ = build_tree_list ($$, $2); }
  3590.     | typed_typespecs declarator
  3591.         { $$ = build_tree_list ($$, $2); }
  3592.     | typespec declarator
  3593.         { $$ = build_tree_list (get_decl_list ($$), $2); }
  3594.     | typed_declspecs1 absdcl
  3595.         { $$ = build_tree_list ($$, $2); }
  3596.     | typed_declspecs1 %prec EMPTY
  3597.         { $$ = build_tree_list ($$, NULL_TREE); }
  3598.     | declmods notype_declarator
  3599.         { $$ = build_tree_list ($$, $2); }
  3600.     ;
  3601.  
  3602. parm:
  3603.     named_parm
  3604.     | type_id
  3605.     ;
  3606.  
  3607. see_typename: %prec EMPTY
  3608.     { see_typename (); }
  3609.     ;
  3610.  
  3611. /* 
  3612. dont_see_typename: %prec EMPTY
  3613.     { dont_see_typename (); }
  3614.     ; 
  3615.  
  3616. try_for_typename:
  3617.         {
  3618.       if ($<ttype>-1 == error_mark_node)
  3619.             $$ = 0;
  3620.           else
  3621.             {
  3622.               $$ = 1;
  3623.               pushclass ($<ttype>-1, 1);
  3624.             }
  3625.         }
  3626.     ;
  3627. */
  3628.  
  3629. bad_parm:
  3630.       /* empty */ %prec EMPTY
  3631.         {
  3632.           warning ("type specifier omitted for parameter");
  3633.           $$ = build_tree_list (TREE_PURPOSE (TREE_VALUE ($<ttype>-1)), NULL_TREE);
  3634.         }
  3635.     | notype_declarator
  3636.         {
  3637.           warning ("type specifier omitted for parameter");
  3638.           $$ = build_tree_list (TREE_PURPOSE (TREE_VALUE ($<ttype>-1)), $$);
  3639.         }
  3640.     ;
  3641.  
  3642. maybe_raises:
  3643.       %prec EMPTY /* empty */
  3644.         { $$ = NULL_TREE; }
  3645.     | THROW '(' ansi_raise_identifiers  ')' %prec EMPTY
  3646.         { $$ = $3; }
  3647.     ;
  3648.  
  3649. ansi_raise_identifier:
  3650.       type_id
  3651.         { $$ = build_decl_list (NULL_TREE, $$); }
  3652.     ;
  3653.  
  3654. ansi_raise_identifiers:
  3655.       ansi_raise_identifier
  3656.     | ansi_raise_identifiers ',' ansi_raise_identifier
  3657.         {
  3658.           TREE_CHAIN ($3) = $$;
  3659.           $$ = $3;
  3660.         }
  3661.     ;
  3662.  
  3663. conversion_declarator:
  3664.       /* empty */ %prec EMPTY
  3665.         { $$ = NULL_TREE; }
  3666.     | '*' type_quals conversion_declarator
  3667.         { $$ = make_pointer_declarator ($2, $3); }
  3668.     | '&' type_quals conversion_declarator
  3669.         { $$ = make_reference_declarator ($2, $3); }
  3670.     | ptr_to_mem type_quals conversion_declarator
  3671.         { tree arg = make_pointer_declarator ($2, $3);
  3672.           $$ = build_parse_node (SCOPE_REF, $1, arg);
  3673.         }
  3674.     ;
  3675.  
  3676. operator: OPERATOR
  3677.         { got_scope = NULL_TREE; }
  3678.     ;
  3679.  
  3680. operator_name:
  3681.       operator '*'
  3682.         { $$ = ansi_opname[MULT_EXPR]; }
  3683.     | operator '/'
  3684.         { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
  3685.     | operator '%'
  3686.         { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
  3687.     | operator '+'
  3688.         { $$ = ansi_opname[PLUS_EXPR]; }
  3689.     | operator '-'
  3690.         { $$ = ansi_opname[MINUS_EXPR]; }
  3691.     | operator '&'
  3692.         { $$ = ansi_opname[BIT_AND_EXPR]; }
  3693.     | operator '|'
  3694.         { $$ = ansi_opname[BIT_IOR_EXPR]; }
  3695.     | operator '^'
  3696.         { $$ = ansi_opname[BIT_XOR_EXPR]; }
  3697.     | operator '~'
  3698.         { $$ = ansi_opname[BIT_NOT_EXPR]; }
  3699.     | operator ','
  3700.         { $$ = ansi_opname[COMPOUND_EXPR]; }
  3701.     | operator ARITHCOMPARE
  3702.         { $$ = ansi_opname[$2]; }
  3703.     | operator '<'
  3704.         { $$ = ansi_opname[LT_EXPR]; }
  3705.     | operator '>'
  3706.         { $$ = ansi_opname[GT_EXPR]; }
  3707.     | operator EQCOMPARE
  3708.         { $$ = ansi_opname[$2]; }
  3709.     | operator ASSIGN
  3710.         { $$ = ansi_assopname[$2]; }
  3711.     | operator '='
  3712.         { $$ = ansi_opname [MODIFY_EXPR]; }
  3713.     | operator LSHIFT
  3714.         { $$ = ansi_opname[$2]; }
  3715.     | operator RSHIFT
  3716.         { $$ = ansi_opname[$2]; }
  3717.     | operator PLUSPLUS
  3718.         { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
  3719.     | operator MINUSMINUS
  3720.         { $$ = ansi_opname[PREDECREMENT_EXPR]; }
  3721.     | operator ANDAND
  3722.         { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
  3723.     | operator OROR
  3724.         { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
  3725.     | operator '!'
  3726.         { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
  3727.     | operator '?' ':'
  3728.         { $$ = ansi_opname[COND_EXPR]; }
  3729.     | operator MIN_MAX
  3730.         { $$ = ansi_opname[$2]; }
  3731.     | operator POINTSAT  %prec EMPTY
  3732.         { $$ = ansi_opname[COMPONENT_REF]; }
  3733.     | operator POINTSAT_STAR  %prec EMPTY
  3734.         { $$ = ansi_opname[MEMBER_REF]; }
  3735.     | operator LEFT_RIGHT
  3736.         { $$ = ansi_opname[CALL_EXPR]; }
  3737.     | operator '[' ']'
  3738.         { $$ = ansi_opname[ARRAY_REF]; }
  3739.     | operator NEW %prec EMPTY
  3740.         { $$ = ansi_opname[NEW_EXPR]; }
  3741.     | operator DELETE %prec EMPTY
  3742.         { $$ = ansi_opname[DELETE_EXPR]; }
  3743.     | operator NEW '[' ']'
  3744.         { $$ = ansi_opname[VEC_NEW_EXPR]; }
  3745.     | operator DELETE '[' ']'
  3746.         { $$ = ansi_opname[VEC_DELETE_EXPR]; }
  3747.     /* Names here should be looked up in class scope ALSO.  */
  3748.     | operator type_specifier_seq conversion_declarator
  3749.         { $$ = grokoptypename ($2, $3); }
  3750.     | operator error
  3751.         { $$ = ansi_opname[ERROR_MARK]; }
  3752.     ;
  3753.  
  3754. %%
  3755.